escape html entities in the option values and output

This commit is contained in:
mohrt
2002-12-10 15:20:09 +00:00
parent 9b25d35767
commit 556a9fc9df
3 changed files with 9 additions and 6 deletions

1
NEWS
View File

@@ -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,

View File

@@ -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);
}

View File

@@ -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);
}