From 1bf1b0584630e6b1c253b4c5a953c10485827bdf Mon Sep 17 00:00:00 2001 From: rodneyrehm Date: Fri, 7 Oct 2011 12:11:33 +0000 Subject: [PATCH] - bugfix html_options plugin did not handle object values properly (Issue #49, Forum Topic 20049) --- change_log.txt | 1 + libs/plugins/function.html_options.php | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/change_log.txt b/change_log.txt index bfdb8b4b..fba8e245 100644 --- a/change_log.txt +++ b/change_log.txt @@ -3,6 +3,7 @@ - improvement removed html comments from {mailto} (Forum Topic 20092) - bugfix testInstall() would not show path to internal plugins_dir (Forum Post 74627) - improvement testInstall() now showing resolved paths and checking the include_path if necessary +- bugfix html_options plugin did not handle object values properly (Issue #49, Forum Topic 20049) 06.10.2011 - bugfix switch lexer internals depending on mbstring.func_overload diff --git a/libs/plugins/function.html_options.php b/libs/plugins/function.html_options.php index 80a9e029..94c4a903 100644 --- a/libs/plugins/function.html_options.php +++ b/libs/plugins/function.html_options.php @@ -143,7 +143,15 @@ function smarty_function_html_options_optoutput($key, $value, $selected, $id, $c } $_html_class = !empty($class) ? ' class="'.$class.' option"' : ''; $_html_id = !empty($id) ? ' id="'.$id.'-'.$idx.'"' : ''; - $_html_result .= $_html_class . $_html_id . '>' . smarty_function_escape_special_chars($value) . '' . "\n"; + if (is_object($value)) { + if (method_exists($value, "__toString")) { + $value = smarty_function_escape_special_chars((string) $value->__toString()); + } else { + trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE); + return ''; + } + } + $_html_result .= $_html_class . $_html_id . '>' . $value . '' . "\n"; $idx++; } else { $_idx = 0;