@@ -44,51 +44,51 @@ |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | switch ($format) { |
47 | - case 'html': |
|
48 | - return htmlspecialchars((string)$value, ENT_QUOTES, $charset); |
|
49 | - case 'htmlall': |
|
50 | - return htmlentities((string)$value, ENT_QUOTES, $charset); |
|
51 | - case 'url': |
|
52 | - return rawurlencode((string)$value); |
|
53 | - case 'urlpathinfo': |
|
54 | - return str_replace('%2F', '/', rawurlencode((string)$value)); |
|
55 | - case 'quotes': |
|
56 | - return preg_replace("#(?<!\\\\)'#", "\\'", (string)$value); |
|
57 | - case 'hex': |
|
58 | - $out = ''; |
|
59 | - $cnt = strlen((string)$value); |
|
60 | - for ($i = 0; $i < $cnt; ++ $i) { |
|
61 | - $out .= '%' . bin2hex((string)$value[$i]); |
|
62 | - } |
|
47 | + case 'html': |
|
48 | + return htmlspecialchars((string)$value, ENT_QUOTES, $charset); |
|
49 | + case 'htmlall': |
|
50 | + return htmlentities((string)$value, ENT_QUOTES, $charset); |
|
51 | + case 'url': |
|
52 | + return rawurlencode((string)$value); |
|
53 | + case 'urlpathinfo': |
|
54 | + return str_replace('%2F', '/', rawurlencode((string)$value)); |
|
55 | + case 'quotes': |
|
56 | + return preg_replace("#(?<!\\\\)'#", "\\'", (string)$value); |
|
57 | + case 'hex': |
|
58 | + $out = ''; |
|
59 | + $cnt = strlen((string)$value); |
|
60 | + for ($i = 0; $i < $cnt; ++ $i) { |
|
61 | + $out .= '%' . bin2hex((string)$value[$i]); |
|
62 | + } |
|
63 | 63 | |
64 | - return $out; |
|
65 | - case 'hexentity': |
|
66 | - $out = ''; |
|
67 | - $cnt = strlen((string)$value); |
|
68 | - for ($i = 0; $i < $cnt; ++ $i) { |
|
69 | - $out .= '&#x' . bin2hex((string)$value[$i]) . ';'; |
|
70 | - } |
|
64 | + return $out; |
|
65 | + case 'hexentity': |
|
66 | + $out = ''; |
|
67 | + $cnt = strlen((string)$value); |
|
68 | + for ($i = 0; $i < $cnt; ++ $i) { |
|
69 | + $out .= '&#x' . bin2hex((string)$value[$i]) . ';'; |
|
70 | + } |
|
71 | 71 | |
72 | - return $out; |
|
73 | - case 'javascript': |
|
74 | - case 'js': |
|
75 | - return strtr((string)$value, array( |
|
76 | - '\\' => '\\\\', |
|
77 | - "'" => "\\'", |
|
78 | - '"' => '\\"', |
|
79 | - "\r" => '\\r', |
|
80 | - "\n" => '\\n', |
|
81 | - '</' => '<\/' |
|
82 | - )); |
|
83 | - case 'mail': |
|
84 | - return str_replace(array( |
|
85 | - '@', |
|
86 | - '.' |
|
87 | - ), array( |
|
88 | - ' (AT) ', |
|
89 | - ' (DOT) ' |
|
90 | - ), (string)$value); |
|
91 | - default: |
|
92 | - $dwoo->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript or mail, "' . $format . '" given.', E_USER_WARNING); |
|
72 | + return $out; |
|
73 | + case 'javascript': |
|
74 | + case 'js': |
|
75 | + return strtr((string)$value, array( |
|
76 | + '\\' => '\\\\', |
|
77 | + "'" => "\\'", |
|
78 | + '"' => '\\"', |
|
79 | + "\r" => '\\r', |
|
80 | + "\n" => '\\n', |
|
81 | + '</' => '<\/' |
|
82 | + )); |
|
83 | + case 'mail': |
|
84 | + return str_replace(array( |
|
85 | + '@', |
|
86 | + '.' |
|
87 | + ), array( |
|
88 | + ' (AT) ', |
|
89 | + ' (DOT) ' |
|
90 | + ), (string)$value); |
|
91 | + default: |
|
92 | + $dwoo->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript or mail, "' . $format . '" given.', E_USER_WARNING); |
|
93 | 93 | } |
94 | 94 | } |