aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/smarty/smarty/libs/plugins/modifier.escape.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/smarty/smarty/libs/plugins/modifier.escape.php')
-rw-r--r--vendor/smarty/smarty/libs/plugins/modifier.escape.php60
1 files changed, 44 insertions, 16 deletions
diff --git a/vendor/smarty/smarty/libs/plugins/modifier.escape.php b/vendor/smarty/smarty/libs/plugins/modifier.escape.php
index 9c247b933..1ae87a7aa 100644
--- a/vendor/smarty/smarty/libs/plugins/modifier.escape.php
+++ b/vendor/smarty/smarty/libs/plugins/modifier.escape.php
@@ -8,8 +8,8 @@
/**
* Smarty escape modifier plugin
- * Type: modifier<br>
- * Name: escape<br>
+ * Type: modifier
+ * Name: escape
* Purpose: escape string for output
*
* @link http://www.smarty.net/docs/en/language.modifier.escape
@@ -25,6 +25,8 @@
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true)
{
static $_double_encode = null;
+ static $is_loaded_1 = false;
+ static $is_loaded_2 = false;
if ($_double_encode === null) {
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
}
@@ -46,7 +48,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
// php <5.2.3 - prevent double encoding
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
- $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
+ $string = str_replace(array('%%%SMARTY_START%%%',
+ '%%%SMARTY_END%%%'), array('&',
+ ';'), $string);
return $string;
}
@@ -67,7 +71,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
$string =
- str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
+ str_replace(array('%%%SMARTY_START%%%',
+ '%%%SMARTY_END%%%'), array('&',
+ ';'), $string);
return $string;
}
@@ -86,7 +92,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
} else {
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
$string = htmlentities($string, ENT_QUOTES, $char_set);
- $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
+ $string = str_replace(array('%%%SMARTY_START%%%',
+ '%%%SMARTY_END%%%'), array('&',
+ ';'), $string);
return $string;
}
@@ -116,8 +124,11 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
case 'hexentity':
$return = '';
if (Smarty::$_MBSTRING) {
- if (!is_callable('smarty_mb_to_unicode')) {
- require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
+ if (!$is_loaded_1) {
+ if (!is_callable('smarty_mb_to_unicode')) {
+ require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
+ }
+ $is_loaded_1 = true;
}
$return = '';
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
@@ -137,8 +148,11 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
case 'decentity':
$return = '';
if (Smarty::$_MBSTRING) {
- if (!is_callable('smarty_mb_to_unicode')) {
- require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
+ if (!$is_loaded_1) {
+ if (!is_callable('smarty_mb_to_unicode')) {
+ require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
+ }
+ $is_loaded_1 = true;
}
$return = '';
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
@@ -157,25 +171,39 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
case 'javascript':
// escape quotes and backslashes, newlines, etc.
- return strtr($string, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n',
+ return strtr($string, array('\\' => '\\\\',
+ "'" => "\\'",
+ '"' => '\\"',
+ "\r" => '\\r',
+ "\n" => '\\n',
'</' => '<\/'));
case 'mail':
if (Smarty::$_MBSTRING) {
- if (!is_callable('smarty_mb_str_replace')) {
- require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
+ if (!$is_loaded_2) {
+ if (!is_callable('smarty_mb_str_replace')) {
+ require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
+ }
+ $is_loaded_2 = true;
}
- return smarty_mb_str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string);
+ return smarty_mb_str_replace(array('@',
+ '.'), array(' [AT] ',
+ ' [DOT] '), $string);
}
// no MBString fallback
- return str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string);
+ return str_replace(array('@',
+ '.'), array(' [AT] ',
+ ' [DOT] '), $string);
case 'nonstd':
// escape non-standard chars, such as ms document quotes
$return = '';
if (Smarty::$_MBSTRING) {
- if (!is_callable('smarty_mb_to_unicode')) {
- require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
+ if (!$is_loaded_1) {
+ if (!is_callable('smarty_mb_to_unicode')) {
+ require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
+ }
+ $is_loaded_1 = true;
}
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
if ($unicode >= 126) {