summaryrefslogtreecommitdiffstats
path: root/system/core/Common.php
diff options
context:
space:
mode:
authorPascal Kriete <pascal.kriete@ellislab.com>2011-04-05 20:52:03 +0200
committerPascal Kriete <pascal.kriete@ellislab.com>2011-04-05 20:52:03 +0200
commit0ff50269e6bac31870a4d69bf4bc0bb895999f1f (patch)
treeb20a3c39eb4590fb4351527f71fbf103f66e491f /system/core/Common.php
parentc9c045a7feee07563c8d14bac3381f7af0e17280 (diff)
tweaking remove_invisible_characters to make urlencoded character stripping optional
Diffstat (limited to 'system/core/Common.php')
-rw-r--r--system/core/Common.php28
1 files changed, 13 insertions, 15 deletions
diff --git a/system/core/Common.php b/system/core/Common.php
index f424a2cc9..b4bd5b097 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -477,28 +477,26 @@
* @param string
* @return string
*/
- function remove_invisible_characters($str)
+ function remove_invisible_characters($str, $url_encoded = TRUE)
{
- static $non_displayables;
-
- if ( ! isset($non_displayables))
+ $non_displayables = array();
+
+ // every control character except newline (dec 10)
+ // carriage return (dec 13), and horizontal tab (dec 09)
+
+ if ($url_encoded)
{
- // every control character except newline (dec 10), carriage return (dec 13), and horizontal tab (dec 09),
- $non_displayables = array(
- '/%0[0-8bcef]/', // url encoded 00-08, 11, 12, 14, 15
- '/%1[0-9a-f]/', // url encoded 16-31
- '/[\x00-\x08]/', // 00-08
- '/\x0b/', '/\x0c/', // 11, 12
- '/[\x0e-\x1f]/' // 14-31
- );
+ $non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15
+ $non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31
}
+
+ $non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127
do
{
- $cleaned = $str;
- $str = preg_replace($non_displayables, '', $str);
+ $str = preg_replace($non_displayables, '', $str, -1, $count);
}
- while ($cleaned != $str);
+ while ($count);
return $str;
}