From a7106ed3111432c0801eef9ee9f6a72168e75195 Mon Sep 17 00:00:00 2001 From: mohrt Date: Mon, 6 Jan 2003 23:15:27 +0000 Subject: [PATCH] add javascript escape parameter to escape modifier --- NEWS | 10 ++++++---- docs/html.dsl | 2 +- libs/plugins/modifier.escape.php | 4 ++++ plugins/modifier.escape.php | 4 ++++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index a4478382..faa70e07 100644 --- a/NEWS +++ b/NEWS @@ -1,11 +1,13 @@ + - add javascript parameter to escape modifier (Monte) + - added correct line numbers to syntax error messages + in compiler (Monte) - added support for modifiers to function calls (Monte) - support return value for custom functions (Monte) - can access constants via $smarty.const.FOO (Monte) - cleaned up regex code in compiler (Monte) - - can now pass modifiers to static content, - among other minor syntax features (monte) - - fix up regex code in compiler, make much more flexible - (Monte) + - can now pass modifiers to static content (Monte) + - fix up regex code in compiler, more flexible and + maintainable (Monte) - added support for object method access (Monte) - added day_value_format to html_select_date (Marcus Bointon, Monte) diff --git a/docs/html.dsl b/docs/html.dsl index e312da30..82a5e5f8 100644 --- a/docs/html.dsl +++ b/docs/html.dsl @@ -8,7 +8,7 @@ -(define %html-ext% ".html") +(define %html-ext% ".php") &html-common.dsl; &common.dsl; diff --git a/libs/plugins/modifier.escape.php b/libs/plugins/modifier.escape.php index b49eec4b..ac4fba7e 100644 --- a/libs/plugins/modifier.escape.php +++ b/libs/plugins/modifier.escape.php @@ -37,6 +37,10 @@ function smarty_modifier_escape($string, $esc_type = 'html') } return $return; + case 'javascript': + // escape quotes and backslashes and newlines + return str_replace(array('\\','\'',"\r","\n"), array("\\\\", "\\'",'\r','\r'), $string); + default: return $string; } diff --git a/plugins/modifier.escape.php b/plugins/modifier.escape.php index b49eec4b..ac4fba7e 100644 --- a/plugins/modifier.escape.php +++ b/plugins/modifier.escape.php @@ -37,6 +37,10 @@ function smarty_modifier_escape($string, $esc_type = 'html') } return $return; + case 'javascript': + // escape quotes and backslashes and newlines + return str_replace(array('\\','\'',"\r","\n"), array("\\\\", "\\'",'\r','\r'), $string); + default: return $string; }