cvs: smarty /libs/plugins function.html_checkboxes.php function.html_image.php function.html_options.php function.html_radios.php
shared.escape_special_chars.php

From: Date: Mon, 14 Apr 2003 16:57:40 +0000
Subject: cvs: smarty /libs/plugins function.html_checkboxes.php function.html_image.php function.html_options.php function.html_radios.php
shared.escape_special_chars.php
Groups: php.smarty.cvs 
Request: Send a blank email to php-smarty-cvs+get-522@lists.php.net to get a copy of this message
mohrt Mon Apr 14 12:57:40 2003 EDT Modified files: /smarty/libs/plugins function.html_checkboxes.php function.html_image.php function.html_options.php function.html_radios.php shared.escape_special_chars.php Log: add appropriate warnings when passing array as extra parameter Index: smarty/libs/plugins/function.html_checkboxes.php diff -u smarty/libs/plugins/function.html_checkboxes.php:1.8 smarty/libs/plugins/function.html_checkboxes.php:1.9 --- smarty/libs/plugins/function.html_checkboxes.php:1.8 Mon Apr 14 03:47:49 2003 +++ smarty/libs/plugins/function.html_checkboxes.php Mon Apr 14 12:57:40 2003 @@ -67,7 +67,11 @@ 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; } } Index: smarty/libs/plugins/function.html_image.php diff -u smarty/libs/plugins/function.html_image.php:1.11 smarty/libs/plugins/function.html_image.php:1.12 --- smarty/libs/plugins/function.html_image.php:1.11 Mon Mar 17 10:39:28 2003 +++ smarty/libs/plugins/function.html_image.php Mon Apr 14 12:57:40 2003 @@ -63,7 +63,11 @@ $dpi = $_val; break; default: - $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; + 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; } } Index: smarty/libs/plugins/function.html_options.php diff -u smarty/libs/plugins/function.html_options.php:1.15 smarty/libs/plugins/function.html_options.php:1.16 --- smarty/libs/plugins/function.html_options.php:1.15 Tue Mar 18 16:04:13 2003 +++ smarty/libs/plugins/function.html_options.php Mon Apr 14 12:57:40 2003 @@ -26,27 +26,31 @@ $extra = ''; - foreach($params as $_key => $_val) { - switch($_key) { - case 'name': - $$_key = (string)$_val; - break; + foreach($params as $_key => $_val) { + switch($_key) { + case 'name': + $$_key = (string)$_val; + break; - case 'options': - $$_key = (array)$_val; - break; + case 'options': + $$_key = (array)$_val; + break; - case 'selected': - case 'values': - case 'output': - $$_key = array_values((array)$_val); - break; + case 'selected': + case 'values': + case 'output': + $$_key = array_values((array)$_val); + break; - default: - $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; - 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; + } + } if (!isset($options) && !isset($values)) return ''; /* raise error here? */ Index: smarty/libs/plugins/function.html_radios.php diff -u smarty/libs/plugins/function.html_radios.php:1.13 smarty/libs/plugins/function.html_radios.php:1.14 --- smarty/libs/plugins/function.html_radios.php:1.13 Mon Apr 14 03:47:49 2003 +++ smarty/libs/plugins/function.html_radios.php Mon Apr 14 12:57:40 2003 @@ -71,7 +71,11 @@ 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; } } Index: smarty/libs/plugins/shared.escape_special_chars.php diff -u smarty/libs/plugins/shared.escape_special_chars.php:1.1 smarty/libs/plugins/shared.escape_special_chars.php:1.2 --- smarty/libs/plugins/shared.escape_special_chars.php:1.1 Mon Feb 24 16:45:19 2003 +++ smarty/libs/plugins/shared.escape_special_chars.php Mon Apr 14 12:57:40 2003 @@ -6,10 +6,12 @@ special chars except for already escaped ones \*======================================================================*/ function smarty_function_escape_special_chars($string) -{ - $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); - $string = htmlspecialchars($string); - $string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $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; }

« previous php.smarty.cvs (#522) next »