From: fabien Date: Tue, 20 Oct 2009 04:25:01 +0000 (+0000) Subject: added a js escaping strategy X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=4a5173151d4ee3e923a9f5fba85f2aaa77cf8d34;p=konrad%2Ftwig.git added a js escaping strategy git-svn-id: http://svn.twig-project.org/trunk@81 93ef8e89-cb99-4229-a87c-7fa0fa45744b --- diff --git a/bin/create_pear_package.php b/bin/create_pear_package.php index e9ebf6c..0ed7a89 100644 --- a/bin/create_pear_package.php +++ b/bin/create_pear_package.php @@ -1,8 +1,5 @@ getCharset()); + switch ($type) + { + case 'js': + // a function the c-escapes a string, making it suitable to be placed in a JavaScript string + return str_replace(array("\\" , "\n" , "\r" , "\"" , "'"), + array("\\\\", "\\n" , "\\r", "\\\"", "\\'"), + $string); + case 'html': + default: + return htmlspecialchars($string, ENT_QUOTES, $env->getCharset()); + } } // add multibyte extensions if possible