diff --git a/NEWS b/NEWS index 18cdf59e..533e3a54 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ + - fixed proper escaping of " and ' with escape:javascript (messju) - fixed bug in traversal of $smarty->plugins_dir-array. now the first matching plugin is taken (messju) - moved {strip} back into the compiler (messju) diff --git a/libs/plugins/modifier.escape.php b/libs/plugins/modifier.escape.php index cd44ba46..f9d0eed9 100644 --- a/libs/plugins/modifier.escape.php +++ b/libs/plugins/modifier.escape.php @@ -51,7 +51,7 @@ function smarty_modifier_escape($string, $esc_type = 'html') case 'javascript': // escape quotes and backslashes and newlines - return str_replace(array('\\','\'',"\r","\n"), array("\\\\", "\\'",'\r','\n'), $string); + return strtr($string, array('\\'=>'\\\\',"'"=>"\\'",'"'=>'\\"',"\r"=>'\\r',"\n"=>'\\n')); default: return $string;