mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
add appropriate warnings when passing array as extra parameter
This commit is contained in:
@@ -67,7 +67,11 @@ function smarty_function_html_checkboxes($params, &$smarty)
|
||||
break;
|
||||
|
||||
default:
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars((string)$_val).'"';
|
||||
if(!is_array($_val)) {
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
||||
} else {
|
||||
$smarty->trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -63,7 +63,11 @@ function smarty_function_html_image($params, &$smarty)
|
||||
$dpi = $_val;
|
||||
break;
|
||||
default:
|
||||
if(!is_array($_val)) {
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
||||
} else {
|
||||
$smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -43,7 +43,11 @@ function smarty_function_html_options($params, &$smarty)
|
||||
break;
|
||||
|
||||
default:
|
||||
if(!is_array($_val)) {
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
||||
} else {
|
||||
$smarty->trigger_error("html_options: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -71,7 +71,11 @@ function smarty_function_html_radios($params, &$smarty)
|
||||
|
||||
|
||||
default:
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars((string)$_val).'"';
|
||||
if(!is_array($_val)) {
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
||||
} else {
|
||||
$smarty->trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -7,9 +7,11 @@
|
||||
\*======================================================================*/
|
||||
function smarty_function_escape_special_chars($string)
|
||||
{
|
||||
if(!is_array($string)) {
|
||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||
$string = htmlspecialchars($string);
|
||||
$string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user