@@ -30,14 +30,14 @@ |
||
30 | 30 | */ |
31 | 31 | class PluginLower extends Plugin implements ICompilable |
32 | 32 | { |
33 | - /** |
|
34 | - * @param Compiler $compiler |
|
35 | - * @param string $value |
|
36 | - * |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - public static function compile(Compiler $compiler, $value) |
|
40 | - { |
|
41 | - return 'mb_strtolower((string) ' . $value . ', $this->charset)'; |
|
42 | - } |
|
33 | + /** |
|
34 | + * @param Compiler $compiler |
|
35 | + * @param string $value |
|
36 | + * |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + public static function compile(Compiler $compiler, $value) |
|
40 | + { |
|
41 | + return 'mb_strtolower((string) ' . $value . ', $this->charset)'; |
|
42 | + } |
|
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -38,6 +38,6 @@ |
||
38 | 38 | */ |
39 | 39 | public static function compile(Compiler $compiler, $value) |
40 | 40 | { |
41 | - return 'mb_strtolower((string) ' . $value . ', $this->charset)'; |
|
41 | + return 'mb_strtolower((string) '.$value.', $this->charset)'; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -30,53 +30,53 @@ |
||
30 | 30 | */ |
31 | 31 | class PluginFetch extends Plugin |
32 | 32 | { |
33 | - /** |
|
34 | - * @param string $file |
|
35 | - * @param null $assign |
|
36 | - * |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - public function process($file, $assign = null) |
|
40 | - { |
|
41 | - if ($file === '') { |
|
42 | - return ''; |
|
43 | - } |
|
33 | + /** |
|
34 | + * @param string $file |
|
35 | + * @param null $assign |
|
36 | + * |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + public function process($file, $assign = null) |
|
40 | + { |
|
41 | + if ($file === '') { |
|
42 | + return ''; |
|
43 | + } |
|
44 | 44 | |
45 | - if ($policy = $this->core->getSecurityPolicy()) { |
|
46 | - while (true) { |
|
47 | - if (preg_match('{^([a-z]+?)://}i', $file)) { |
|
48 | - $this->core->triggerError('The security policy prevents you to read files from external sources.', |
|
49 | - E_USER_WARNING); |
|
50 | - } |
|
45 | + if ($policy = $this->core->getSecurityPolicy()) { |
|
46 | + while (true) { |
|
47 | + if (preg_match('{^([a-z]+?)://}i', $file)) { |
|
48 | + $this->core->triggerError('The security policy prevents you to read files from external sources.', |
|
49 | + E_USER_WARNING); |
|
50 | + } |
|
51 | 51 | |
52 | - $file = realpath($file); |
|
53 | - $dirs = $policy->getAllowedDirectories(); |
|
54 | - foreach ($dirs as $dir => $dummy) { |
|
55 | - if (strpos($file, $dir) === 0) { |
|
56 | - break 2; |
|
57 | - } |
|
58 | - } |
|
59 | - $this->core->triggerError('The security policy prevents you to read <em>' . $file . '</em>', |
|
60 | - E_USER_WARNING); |
|
61 | - } |
|
62 | - } |
|
63 | - $file = str_replace(array( |
|
64 | - "\t", |
|
65 | - "\n", |
|
66 | - "\r" |
|
67 | - ), |
|
68 | - array( |
|
69 | - '\\t', |
|
70 | - '\\n', |
|
71 | - '\\r' |
|
72 | - ), |
|
73 | - $file); |
|
52 | + $file = realpath($file); |
|
53 | + $dirs = $policy->getAllowedDirectories(); |
|
54 | + foreach ($dirs as $dir => $dummy) { |
|
55 | + if (strpos($file, $dir) === 0) { |
|
56 | + break 2; |
|
57 | + } |
|
58 | + } |
|
59 | + $this->core->triggerError('The security policy prevents you to read <em>' . $file . '</em>', |
|
60 | + E_USER_WARNING); |
|
61 | + } |
|
62 | + } |
|
63 | + $file = str_replace(array( |
|
64 | + "\t", |
|
65 | + "\n", |
|
66 | + "\r" |
|
67 | + ), |
|
68 | + array( |
|
69 | + '\\t', |
|
70 | + '\\n', |
|
71 | + '\\r' |
|
72 | + ), |
|
73 | + $file); |
|
74 | 74 | |
75 | - $out = file_get_contents($file); |
|
75 | + $out = file_get_contents($file); |
|
76 | 76 | |
77 | - if ($assign === null) { |
|
78 | - return $out; |
|
79 | - } |
|
80 | - $this->core->assignInScope($out, $assign); |
|
81 | - } |
|
77 | + if ($assign === null) { |
|
78 | + return $out; |
|
79 | + } |
|
80 | + $this->core->assignInScope($out, $assign); |
|
81 | + } |
|
82 | 82 | } |
83 | 83 | \ No newline at end of file |
@@ -56,7 +56,7 @@ |
||
56 | 56 | break 2; |
57 | 57 | } |
58 | 58 | } |
59 | - $this->core->triggerError('The security policy prevents you to read <em>' . $file . '</em>', |
|
59 | + $this->core->triggerError('The security policy prevents you to read <em>'.$file.'</em>', |
|
60 | 60 | E_USER_WARNING); |
61 | 61 | } |
62 | 62 | } |
@@ -33,17 +33,17 @@ |
||
33 | 33 | */ |
34 | 34 | class PluginWordwrap extends Plugin implements ICompilable |
35 | 35 | { |
36 | - /** |
|
37 | - * @param Compiler $compiler |
|
38 | - * @param string $value |
|
39 | - * @param int $length |
|
40 | - * @param string $break |
|
41 | - * @param bool $cut |
|
42 | - * |
|
43 | - * @return string |
|
44 | - */ |
|
45 | - public static function compile(Compiler $compiler, $value, $length = 80, $break = "\n", $cut = false) |
|
46 | - { |
|
47 | - return 'wordwrap(' . $value . ',' . $length . ',' . $break . ',' . $cut . ')'; |
|
48 | - } |
|
36 | + /** |
|
37 | + * @param Compiler $compiler |
|
38 | + * @param string $value |
|
39 | + * @param int $length |
|
40 | + * @param string $break |
|
41 | + * @param bool $cut |
|
42 | + * |
|
43 | + * @return string |
|
44 | + */ |
|
45 | + public static function compile(Compiler $compiler, $value, $length = 80, $break = "\n", $cut = false) |
|
46 | + { |
|
47 | + return 'wordwrap(' . $value . ',' . $length . ',' . $break . ',' . $cut . ')'; |
|
48 | + } |
|
49 | 49 | } |
50 | 50 | \ No newline at end of file |
@@ -44,6 +44,6 @@ |
||
44 | 44 | */ |
45 | 45 | public static function compile(Compiler $compiler, $value, $length = 80, $break = "\n", $cut = false) |
46 | 46 | { |
47 | - return 'wordwrap(' . $value . ',' . $length . ',' . $break . ',' . $cut . ')'; |
|
47 | + return 'wordwrap('.$value.','.$length.','.$break.','.$cut.')'; |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | \ No newline at end of file |
@@ -32,21 +32,21 @@ |
||
32 | 32 | */ |
33 | 33 | class PluginReplace extends Plugin implements ICompilable |
34 | 34 | { |
35 | - /** |
|
36 | - * @param Compiler $compiler |
|
37 | - * @param string $value |
|
38 | - * @param string $search |
|
39 | - * @param string $replace |
|
40 | - * @param bool $case_sensitive |
|
41 | - * |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - public static function compile(Compiler $compiler, $value, $search, $replace, $case_sensitive = true) |
|
45 | - { |
|
46 | - if ($case_sensitive == 'false' || (bool)$case_sensitive === false) { |
|
47 | - return 'str_ireplace(' . $search . ', ' . $replace . ', ' . $value . ')'; |
|
48 | - } else { |
|
49 | - return 'str_replace(' . $search . ', ' . $replace . ', ' . $value . ')'; |
|
50 | - } |
|
51 | - } |
|
35 | + /** |
|
36 | + * @param Compiler $compiler |
|
37 | + * @param string $value |
|
38 | + * @param string $search |
|
39 | + * @param string $replace |
|
40 | + * @param bool $case_sensitive |
|
41 | + * |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + public static function compile(Compiler $compiler, $value, $search, $replace, $case_sensitive = true) |
|
45 | + { |
|
46 | + if ($case_sensitive == 'false' || (bool)$case_sensitive === false) { |
|
47 | + return 'str_ireplace(' . $search . ', ' . $replace . ', ' . $value . ')'; |
|
48 | + } else { |
|
49 | + return 'str_replace(' . $search . ', ' . $replace . ', ' . $value . ')'; |
|
50 | + } |
|
51 | + } |
|
52 | 52 | } |
53 | 53 | \ No newline at end of file |
@@ -43,10 +43,10 @@ |
||
43 | 43 | */ |
44 | 44 | public static function compile(Compiler $compiler, $value, $search, $replace, $case_sensitive = true) |
45 | 45 | { |
46 | - if ($case_sensitive == 'false' || (bool)$case_sensitive === false) { |
|
47 | - return 'str_ireplace(' . $search . ', ' . $replace . ', ' . $value . ')'; |
|
46 | + if ($case_sensitive == 'false' || (bool) $case_sensitive === false) { |
|
47 | + return 'str_ireplace('.$search.', '.$replace.', '.$value.')'; |
|
48 | 48 | } else { |
49 | - return 'str_replace(' . $search . ', ' . $replace . ', ' . $value . ')'; |
|
49 | + return 'str_replace('.$search.', '.$replace.', '.$value.')'; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | } |
53 | 53 | \ No newline at end of file |
@@ -30,34 +30,34 @@ |
||
30 | 30 | */ |
31 | 31 | class PluginRegexReplace extends Plugin |
32 | 32 | { |
33 | - /** |
|
34 | - * @param string $value |
|
35 | - * @param string $search |
|
36 | - * @param string $replace |
|
37 | - * |
|
38 | - * @return mixed |
|
39 | - */ |
|
40 | - public function process($value, $search, $replace) |
|
41 | - { |
|
42 | - $search = (array)$search; |
|
43 | - $cnt = count($search); |
|
33 | + /** |
|
34 | + * @param string $value |
|
35 | + * @param string $search |
|
36 | + * @param string $replace |
|
37 | + * |
|
38 | + * @return mixed |
|
39 | + */ |
|
40 | + public function process($value, $search, $replace) |
|
41 | + { |
|
42 | + $search = (array)$search; |
|
43 | + $cnt = count($search); |
|
44 | 44 | |
45 | - for ($i = 0; $i < $cnt; ++ $i) { |
|
46 | - // Credits for this to Monte Ohrt who made smarty's regex_replace modifier |
|
47 | - if (($pos = strpos($search[$i], "\0")) !== false) { |
|
48 | - $search[$i] = substr($search[$i], 0, $pos); |
|
49 | - } |
|
45 | + for ($i = 0; $i < $cnt; ++ $i) { |
|
46 | + // Credits for this to Monte Ohrt who made smarty's regex_replace modifier |
|
47 | + if (($pos = strpos($search[$i], "\0")) !== false) { |
|
48 | + $search[$i] = substr($search[$i], 0, $pos); |
|
49 | + } |
|
50 | 50 | |
51 | - if (preg_match('#[a-z\s]+$#is', $search[$i], $m) && (strpos($m[0], 'e') !== false)) { |
|
52 | - $search[$i] = substr($search[$i], 0, - strlen($m[0])) . str_replace(array( |
|
53 | - 'e', |
|
54 | - ' ' |
|
55 | - ), |
|
56 | - '', |
|
57 | - $m[0]); |
|
58 | - } |
|
59 | - } |
|
51 | + if (preg_match('#[a-z\s]+$#is', $search[$i], $m) && (strpos($m[0], 'e') !== false)) { |
|
52 | + $search[$i] = substr($search[$i], 0, - strlen($m[0])) . str_replace(array( |
|
53 | + 'e', |
|
54 | + ' ' |
|
55 | + ), |
|
56 | + '', |
|
57 | + $m[0]); |
|
58 | + } |
|
59 | + } |
|
60 | 60 | |
61 | - return preg_replace($search, $replace, $value); |
|
62 | - } |
|
61 | + return preg_replace($search, $replace, $value); |
|
62 | + } |
|
63 | 63 | } |
64 | 64 | \ No newline at end of file |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function process($value, $search, $replace) |
41 | 41 | { |
42 | - $search = (array)$search; |
|
42 | + $search = (array) $search; |
|
43 | 43 | $cnt = count($search); |
44 | 44 | |
45 | 45 | for ($i = 0; $i < $cnt; ++ $i) { |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | if (preg_match('#[a-z\s]+$#is', $search[$i], $m) && (strpos($m[0], 'e') !== false)) { |
52 | - $search[$i] = substr($search[$i], 0, - strlen($m[0])) . str_replace(array( |
|
52 | + $search[$i] = substr($search[$i], 0, - strlen($m[0])).str_replace(array( |
|
53 | 53 | 'e', |
54 | 54 | ' ' |
55 | 55 | ), |
@@ -31,15 +31,15 @@ |
||
31 | 31 | */ |
32 | 32 | class PluginStringFormat extends Plugin implements ICompilable |
33 | 33 | { |
34 | - /** |
|
35 | - * @param Compiler $compiler |
|
36 | - * @param string $value |
|
37 | - * @param string $format |
|
38 | - * |
|
39 | - * @return string |
|
40 | - */ |
|
41 | - public static function compile(Compiler $compiler, $value, $format) |
|
42 | - { |
|
43 | - return 'sprintf(' . $format . ',' . $value . ')'; |
|
44 | - } |
|
34 | + /** |
|
35 | + * @param Compiler $compiler |
|
36 | + * @param string $value |
|
37 | + * @param string $format |
|
38 | + * |
|
39 | + * @return string |
|
40 | + */ |
|
41 | + public static function compile(Compiler $compiler, $value, $format) |
|
42 | + { |
|
43 | + return 'sprintf(' . $format . ',' . $value . ')'; |
|
44 | + } |
|
45 | 45 | } |
46 | 46 | \ No newline at end of file |
@@ -40,6 +40,6 @@ |
||
40 | 40 | */ |
41 | 41 | public static function compile(Compiler $compiler, $value, $format) |
42 | 42 | { |
43 | - return 'sprintf(' . $format . ',' . $value . ')'; |
|
43 | + return 'sprintf('.$format.','.$value.')'; |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | \ No newline at end of file |
@@ -27,13 +27,13 @@ |
||
27 | 27 | */ |
28 | 28 | class PluginEol extends Plugin implements ICompilable |
29 | 29 | { |
30 | - /** |
|
31 | - * @param Compiler $compiler |
|
32 | - * |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public static function compile(Compiler $compiler) |
|
36 | - { |
|
37 | - return 'PHP_EOL'; |
|
38 | - } |
|
30 | + /** |
|
31 | + * @param Compiler $compiler |
|
32 | + * |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public static function compile(Compiler $compiler) |
|
36 | + { |
|
37 | + return 'PHP_EOL'; |
|
38 | + } |
|
39 | 39 | } |
@@ -30,14 +30,14 @@ |
||
30 | 30 | */ |
31 | 31 | class PluginCountParagraphs extends Plugin implements ICompilable |
32 | 32 | { |
33 | - /** |
|
34 | - * @param Compiler $compiler |
|
35 | - * @param string $value |
|
36 | - * |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - public static function compile(Compiler $compiler, $value) |
|
40 | - { |
|
41 | - return '(preg_match_all(\'#[\r\n]+#\', ' . $value . ', $tmp)+1)'; |
|
42 | - } |
|
33 | + /** |
|
34 | + * @param Compiler $compiler |
|
35 | + * @param string $value |
|
36 | + * |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + public static function compile(Compiler $compiler, $value) |
|
40 | + { |
|
41 | + return '(preg_match_all(\'#[\r\n]+#\', ' . $value . ', $tmp)+1)'; |
|
42 | + } |
|
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -38,6 +38,6 @@ |
||
38 | 38 | */ |
39 | 39 | public static function compile(Compiler $compiler, $value) |
40 | 40 | { |
41 | - return '(preg_match_all(\'#[\r\n]+#\', ' . $value . ', $tmp)+1)'; |
|
41 | + return '(preg_match_all(\'#[\r\n]+#\', '.$value.', $tmp)+1)'; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -34,70 +34,70 @@ |
||
34 | 34 | */ |
35 | 35 | class PluginEscape extends Plugin |
36 | 36 | { |
37 | - /** |
|
38 | - * @param string $value |
|
39 | - * @param string $format |
|
40 | - * @param null $charset |
|
41 | - * |
|
42 | - * @return mixed|string |
|
43 | - */ |
|
44 | - public function process($value = '', $format = 'html', $charset = null) |
|
45 | - { |
|
46 | - if ($charset === null) { |
|
47 | - $charset = $this->core->getCharset(); |
|
48 | - } |
|
37 | + /** |
|
38 | + * @param string $value |
|
39 | + * @param string $format |
|
40 | + * @param null $charset |
|
41 | + * |
|
42 | + * @return mixed|string |
|
43 | + */ |
|
44 | + public function process($value = '', $format = 'html', $charset = null) |
|
45 | + { |
|
46 | + if ($charset === null) { |
|
47 | + $charset = $this->core->getCharset(); |
|
48 | + } |
|
49 | 49 | |
50 | - switch ($format) { |
|
51 | - case 'html': |
|
52 | - return htmlspecialchars((string)$value, ENT_QUOTES, $charset); |
|
53 | - case 'htmlall': |
|
54 | - return htmlentities((string)$value, ENT_QUOTES, $charset); |
|
55 | - case 'url': |
|
56 | - return rawurlencode((string)$value); |
|
57 | - case 'urlpathinfo': |
|
58 | - return str_replace('%2F', '/', rawurlencode((string)$value)); |
|
59 | - case 'quotes': |
|
60 | - return preg_replace("#(?<!\\\\)'#", "\\'", (string)$value); |
|
61 | - case 'hex': |
|
62 | - $out = ''; |
|
63 | - $cnt = strlen((string)$value); |
|
64 | - for ($i = 0; $i < $cnt; ++ $i) { |
|
65 | - $out .= '%' . bin2hex((string)$value[$i]); |
|
66 | - } |
|
50 | + switch ($format) { |
|
51 | + case 'html': |
|
52 | + return htmlspecialchars((string)$value, ENT_QUOTES, $charset); |
|
53 | + case 'htmlall': |
|
54 | + return htmlentities((string)$value, ENT_QUOTES, $charset); |
|
55 | + case 'url': |
|
56 | + return rawurlencode((string)$value); |
|
57 | + case 'urlpathinfo': |
|
58 | + return str_replace('%2F', '/', rawurlencode((string)$value)); |
|
59 | + case 'quotes': |
|
60 | + return preg_replace("#(?<!\\\\)'#", "\\'", (string)$value); |
|
61 | + case 'hex': |
|
62 | + $out = ''; |
|
63 | + $cnt = strlen((string)$value); |
|
64 | + for ($i = 0; $i < $cnt; ++ $i) { |
|
65 | + $out .= '%' . bin2hex((string)$value[$i]); |
|
66 | + } |
|
67 | 67 | |
68 | - return $out; |
|
69 | - case 'hexentity': |
|
70 | - $out = ''; |
|
71 | - $cnt = strlen((string)$value); |
|
72 | - for ($i = 0; $i < $cnt; ++ $i) { |
|
73 | - $out .= '&#x' . bin2hex((string)$value[$i]) . ';'; |
|
74 | - } |
|
68 | + return $out; |
|
69 | + case 'hexentity': |
|
70 | + $out = ''; |
|
71 | + $cnt = strlen((string)$value); |
|
72 | + for ($i = 0; $i < $cnt; ++ $i) { |
|
73 | + $out .= '&#x' . bin2hex((string)$value[$i]) . ';'; |
|
74 | + } |
|
75 | 75 | |
76 | - return $out; |
|
77 | - case 'javascript': |
|
78 | - case 'js': |
|
79 | - return strtr((string)$value, |
|
80 | - array( |
|
81 | - '\\' => '\\\\', |
|
82 | - "'" => "\\'", |
|
83 | - '"' => '\\"', |
|
84 | - "\r" => '\\r', |
|
85 | - "\n" => '\\n', |
|
86 | - '</' => '<\/' |
|
87 | - )); |
|
88 | - case 'mail': |
|
89 | - return str_replace(array( |
|
90 | - '@', |
|
91 | - '.' |
|
92 | - ), |
|
93 | - array( |
|
94 | - ' (AT) ', |
|
95 | - ' (DOT) ' |
|
96 | - ), |
|
97 | - (string)$value); |
|
98 | - default: |
|
99 | - $this->core->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript, js or mail, "' . $format . '" given.', |
|
100 | - E_USER_WARNING); |
|
101 | - } |
|
102 | - } |
|
76 | + return $out; |
|
77 | + case 'javascript': |
|
78 | + case 'js': |
|
79 | + return strtr((string)$value, |
|
80 | + array( |
|
81 | + '\\' => '\\\\', |
|
82 | + "'" => "\\'", |
|
83 | + '"' => '\\"', |
|
84 | + "\r" => '\\r', |
|
85 | + "\n" => '\\n', |
|
86 | + '</' => '<\/' |
|
87 | + )); |
|
88 | + case 'mail': |
|
89 | + return str_replace(array( |
|
90 | + '@', |
|
91 | + '.' |
|
92 | + ), |
|
93 | + array( |
|
94 | + ' (AT) ', |
|
95 | + ' (DOT) ' |
|
96 | + ), |
|
97 | + (string)$value); |
|
98 | + default: |
|
99 | + $this->core->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript, js or mail, "' . $format . '" given.', |
|
100 | + E_USER_WARNING); |
|
101 | + } |
|
102 | + } |
|
103 | 103 | } |
104 | 104 | \ No newline at end of file |
@@ -48,56 +48,56 @@ |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | switch ($format) { |
51 | - case 'html': |
|
52 | - return htmlspecialchars((string)$value, ENT_QUOTES, $charset); |
|
53 | - case 'htmlall': |
|
54 | - return htmlentities((string)$value, ENT_QUOTES, $charset); |
|
55 | - case 'url': |
|
56 | - return rawurlencode((string)$value); |
|
57 | - case 'urlpathinfo': |
|
58 | - return str_replace('%2F', '/', rawurlencode((string)$value)); |
|
59 | - case 'quotes': |
|
60 | - return preg_replace("#(?<!\\\\)'#", "\\'", (string)$value); |
|
61 | - case 'hex': |
|
62 | - $out = ''; |
|
63 | - $cnt = strlen((string)$value); |
|
64 | - for ($i = 0; $i < $cnt; ++ $i) { |
|
65 | - $out .= '%' . bin2hex((string)$value[$i]); |
|
66 | - } |
|
51 | + case 'html': |
|
52 | + return htmlspecialchars((string)$value, ENT_QUOTES, $charset); |
|
53 | + case 'htmlall': |
|
54 | + return htmlentities((string)$value, ENT_QUOTES, $charset); |
|
55 | + case 'url': |
|
56 | + return rawurlencode((string)$value); |
|
57 | + case 'urlpathinfo': |
|
58 | + return str_replace('%2F', '/', rawurlencode((string)$value)); |
|
59 | + case 'quotes': |
|
60 | + return preg_replace("#(?<!\\\\)'#", "\\'", (string)$value); |
|
61 | + case 'hex': |
|
62 | + $out = ''; |
|
63 | + $cnt = strlen((string)$value); |
|
64 | + for ($i = 0; $i < $cnt; ++ $i) { |
|
65 | + $out .= '%' . bin2hex((string)$value[$i]); |
|
66 | + } |
|
67 | 67 | |
68 | - return $out; |
|
69 | - case 'hexentity': |
|
70 | - $out = ''; |
|
71 | - $cnt = strlen((string)$value); |
|
72 | - for ($i = 0; $i < $cnt; ++ $i) { |
|
73 | - $out .= '&#x' . bin2hex((string)$value[$i]) . ';'; |
|
74 | - } |
|
68 | + return $out; |
|
69 | + case 'hexentity': |
|
70 | + $out = ''; |
|
71 | + $cnt = strlen((string)$value); |
|
72 | + for ($i = 0; $i < $cnt; ++ $i) { |
|
73 | + $out .= '&#x' . bin2hex((string)$value[$i]) . ';'; |
|
74 | + } |
|
75 | 75 | |
76 | - return $out; |
|
77 | - case 'javascript': |
|
78 | - case 'js': |
|
79 | - return strtr((string)$value, |
|
80 | - array( |
|
81 | - '\\' => '\\\\', |
|
82 | - "'" => "\\'", |
|
83 | - '"' => '\\"', |
|
84 | - "\r" => '\\r', |
|
85 | - "\n" => '\\n', |
|
86 | - '</' => '<\/' |
|
87 | - )); |
|
88 | - case 'mail': |
|
89 | - return str_replace(array( |
|
90 | - '@', |
|
91 | - '.' |
|
76 | + return $out; |
|
77 | + case 'javascript': |
|
78 | + case 'js': |
|
79 | + return strtr((string)$value, |
|
80 | + array( |
|
81 | + '\\' => '\\\\', |
|
82 | + "'" => "\\'", |
|
83 | + '"' => '\\"', |
|
84 | + "\r" => '\\r', |
|
85 | + "\n" => '\\n', |
|
86 | + '</' => '<\/' |
|
87 | + )); |
|
88 | + case 'mail': |
|
89 | + return str_replace(array( |
|
90 | + '@', |
|
91 | + '.' |
|
92 | + ), |
|
93 | + array( |
|
94 | + ' (AT) ', |
|
95 | + ' (DOT) ' |
|
92 | 96 | ), |
93 | - array( |
|
94 | - ' (AT) ', |
|
95 | - ' (DOT) ' |
|
96 | - ), |
|
97 | - (string)$value); |
|
98 | - default: |
|
99 | - $this->core->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript, js or mail, "' . $format . '" given.', |
|
100 | - E_USER_WARNING); |
|
97 | + (string)$value); |
|
98 | + default: |
|
99 | + $this->core->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript, js or mail, "' . $format . '" given.', |
|
100 | + E_USER_WARNING); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | } |
104 | 104 | \ No newline at end of file |
@@ -49,34 +49,34 @@ discard block |
||
49 | 49 | |
50 | 50 | switch ($format) { |
51 | 51 | case 'html': |
52 | - return htmlspecialchars((string)$value, ENT_QUOTES, $charset); |
|
52 | + return htmlspecialchars((string) $value, ENT_QUOTES, $charset); |
|
53 | 53 | case 'htmlall': |
54 | - return htmlentities((string)$value, ENT_QUOTES, $charset); |
|
54 | + return htmlentities((string) $value, ENT_QUOTES, $charset); |
|
55 | 55 | case 'url': |
56 | - return rawurlencode((string)$value); |
|
56 | + return rawurlencode((string) $value); |
|
57 | 57 | case 'urlpathinfo': |
58 | - return str_replace('%2F', '/', rawurlencode((string)$value)); |
|
58 | + return str_replace('%2F', '/', rawurlencode((string) $value)); |
|
59 | 59 | case 'quotes': |
60 | - return preg_replace("#(?<!\\\\)'#", "\\'", (string)$value); |
|
60 | + return preg_replace("#(?<!\\\\)'#", "\\'", (string) $value); |
|
61 | 61 | case 'hex': |
62 | 62 | $out = ''; |
63 | - $cnt = strlen((string)$value); |
|
63 | + $cnt = strlen((string) $value); |
|
64 | 64 | for ($i = 0; $i < $cnt; ++ $i) { |
65 | - $out .= '%' . bin2hex((string)$value[$i]); |
|
65 | + $out .= '%'.bin2hex((string) $value[$i]); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | return $out; |
69 | 69 | case 'hexentity': |
70 | 70 | $out = ''; |
71 | - $cnt = strlen((string)$value); |
|
71 | + $cnt = strlen((string) $value); |
|
72 | 72 | for ($i = 0; $i < $cnt; ++ $i) { |
73 | - $out .= '&#x' . bin2hex((string)$value[$i]) . ';'; |
|
73 | + $out .= '&#x'.bin2hex((string) $value[$i]).';'; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | return $out; |
77 | 77 | case 'javascript': |
78 | 78 | case 'js': |
79 | - return strtr((string)$value, |
|
79 | + return strtr((string) $value, |
|
80 | 80 | array( |
81 | 81 | '\\' => '\\\\', |
82 | 82 | "'" => "\\'", |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | ' (AT) ', |
95 | 95 | ' (DOT) ' |
96 | 96 | ), |
97 | - (string)$value); |
|
97 | + (string) $value); |
|
98 | 98 | default: |
99 | - $this->core->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript, js or mail, "' . $format . '" given.', |
|
99 | + $this->core->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript, js or mail, "'.$format.'" given.', |
|
100 | 100 | E_USER_WARNING); |
101 | 101 | } |
102 | 102 | } |