mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
escape html entities in the option values and output
This commit is contained in:
1
NEWS
1
NEWS
@@ -1,3 +1,4 @@
|
||||
- escape html entities in html_options (Monte)
|
||||
- fixed bug with label for html_options (Monte)
|
||||
- added caching to config file loading (Monte)
|
||||
- added "extra" parameter to mailto function (Monte,
|
||||
|
@@ -43,10 +43,11 @@ function smarty_function_html_options($params, &$smarty)
|
||||
|
||||
function smarty_function_html_options_optoutput($key, $value, $selected) {
|
||||
if(!is_array($value)) {
|
||||
$html_result = "<option label=\"$value\" value=\"$key\"";
|
||||
$html_result = '<option label="' . htmlspecialchars($value) . '" value="' .
|
||||
htmlspecialchars($key) . '"';
|
||||
if (in_array($key, $selected))
|
||||
$html_result .= " selected=\"selected\"";
|
||||
$html_result .= ">$value</option>\n";
|
||||
$html_result .= '>' . htmlspecialchars($value) . '</option>' . "\n";
|
||||
} else {
|
||||
$html_result = smarty_function_html_options_optgroup($key, $value, $selected);
|
||||
}
|
||||
@@ -54,7 +55,7 @@ function smarty_function_html_options_optoutput($key, $value, $selected) {
|
||||
}
|
||||
|
||||
function smarty_function_html_options_optgroup($key, $values, $selected) {
|
||||
$optgroup_html = "<optgroup label=\"$value\">\n";
|
||||
$optgroup_html = '<optgroup label="' . htmlspecialchars($value) . '">' . "\n";
|
||||
foreach ($values as $key => $value) {
|
||||
$optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected);
|
||||
}
|
||||
|
@@ -43,10 +43,11 @@ function smarty_function_html_options($params, &$smarty)
|
||||
|
||||
function smarty_function_html_options_optoutput($key, $value, $selected) {
|
||||
if(!is_array($value)) {
|
||||
$html_result = "<option label=\"$value\" value=\"$key\"";
|
||||
$html_result = '<option label="' . htmlspecialchars($value) . '" value="' .
|
||||
htmlspecialchars($key) . '"';
|
||||
if (in_array($key, $selected))
|
||||
$html_result .= " selected=\"selected\"";
|
||||
$html_result .= ">$value</option>\n";
|
||||
$html_result .= '>' . htmlspecialchars($value) . '</option>' . "\n";
|
||||
} else {
|
||||
$html_result = smarty_function_html_options_optgroup($key, $value, $selected);
|
||||
}
|
||||
@@ -54,7 +55,7 @@ function smarty_function_html_options_optoutput($key, $value, $selected) {
|
||||
}
|
||||
|
||||
function smarty_function_html_options_optgroup($key, $values, $selected) {
|
||||
$optgroup_html = "<optgroup label=\"$value\">\n";
|
||||
$optgroup_html = '<optgroup label="' . htmlspecialchars($value) . '">' . "\n";
|
||||
foreach ($values as $key => $value) {
|
||||
$optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected);
|
||||
}
|
||||
|
Reference in New Issue
Block a user