blob: c1659ab8d42335e97767ee2413e425acc13fb644 [file] [log] [blame]
Derek Jones0b59f272008-05-13 04:22:33 +00001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Derek Allarda72b60d2007-01-31 23:56:11 +00002/**
Derek Allardd2df9bc2007-04-15 17:41:17 +00003 * CodeIgniter
Derek Allarda72b60d2007-01-31 23:56:11 +00004 *
5 * An open source application development framework for PHP 4.3.2 or newer
6 *
7 * @package CodeIgniter
Derek Allard3d879d52008-01-18 19:41:32 +00008 * @author ExpressionEngine Dev Team
Derek Allardd2df9bc2007-04-15 17:41:17 +00009 * @copyright Copyright (c) 2006, EllisLab, Inc.
Derek Jones7a9193a2008-01-21 18:39:20 +000010 * @license http://codeigniter.com/user_guide/license.html
11 * @link http://codeigniter.com
Derek Allarda72b60d2007-01-31 23:56:11 +000012 * @since Version 1.0
13 * @filesource
14 */
15
16// ------------------------------------------------------------------------
17
18/**
19 * Input Class
20 *
21 * Pre-processes global input data for security
22 *
23 * @package CodeIgniter
24 * @subpackage Libraries
25 * @category Input
Derek Allard3d879d52008-01-18 19:41:32 +000026 * @author ExpressionEngine Dev Team
Derek Jones7a9193a2008-01-21 18:39:20 +000027 * @link http://codeigniter.com/user_guide/libraries/input.html
Derek Allarda72b60d2007-01-31 23:56:11 +000028 */
29class CI_Input {
30 var $use_xss_clean = FALSE;
Derek Jones53437de2008-05-12 18:07:08 +000031 var $xss_hash = '';
Derek Allarda72b60d2007-01-31 23:56:11 +000032 var $ip_address = FALSE;
33 var $user_agent = FALSE;
34 var $allow_get_array = FALSE;
Derek Jonese3332b02008-05-13 14:44:32 +000035
36 /* never allowed, string replacement */
37 var $never_allowed_str = array(
38 'document.cookie' => '[removed]',
39 'document.write' => '[removed]',
40 '.parentNode' => '[removed]',
41 '.innerHTML' => '[removed]',
42 'window.location' => '[removed]',
43 '-moz-binding' => '[removed]',
44 '<!--' => '&lt;!--',
45 '-->' => '--&gt;',
46 '<![CDATA[' => '&lt;![CDATA['
47 );
48 /* never allowed, regex replacement */
49 var $never_allowed_regex = array(
50 "javascript\s*:" => '[removed]',
51 "expression\s*\(" => '[removed]', // CSS and IE
52 "Redirect\s+302" => '[removed]'
53 );
54
Derek Allarda72b60d2007-01-31 23:56:11 +000055 /**
56 * Constructor
57 *
58 * Sets whether to globally enable the XSS processing
59 * and whether to allow the $_GET array
60 *
61 * @access public
Derek Allard15dcf492008-05-12 21:37:04 +000062 */
Derek Allarda72b60d2007-01-31 23:56:11 +000063 function CI_Input()
Derek Allard15dcf492008-05-12 21:37:04 +000064 {
Derek Allarda72b60d2007-01-31 23:56:11 +000065 log_message('debug', "Input Class Initialized");
Derek Allard15dcf492008-05-12 21:37:04 +000066
Derek Allarda72b60d2007-01-31 23:56:11 +000067 $CFG =& load_class('Config');
68 $this->use_xss_clean = ($CFG->item('global_xss_filtering') === TRUE) ? TRUE : FALSE;
Derek Allard15dcf492008-05-12 21:37:04 +000069 $this->allow_get_array = ($CFG->item('enable_query_strings') === TRUE) ? TRUE : FALSE;
Derek Allarda72b60d2007-01-31 23:56:11 +000070 $this->_sanitize_globals();
71 }
Derek Allard15dcf492008-05-12 21:37:04 +000072
Derek Allarda72b60d2007-01-31 23:56:11 +000073 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +000074
Derek Allarda72b60d2007-01-31 23:56:11 +000075 /**
76 * Sanitize Globals
77 *
78 * This function does the following:
79 *
80 * Unsets $_GET data (if query strings are not enabled)
81 *
82 * Unsets all globals if register_globals is enabled
83 *
84 * Standardizes newline characters to \n
85 *
86 * @access private
87 * @return void
88 */
89 function _sanitize_globals()
90 {
Derek Jonesd85a11e2008-01-24 20:48:07 +000091 // Would kind of be "wrong" to unset any of these GLOBALS
92 $protected = array('_SERVER', '_GET', '_POST', '_FILES', '_REQUEST', '_SESSION', '_ENV', 'GLOBALS', 'HTTP_RAW_POST_DATA',
93 'system_folder', 'application_folder', 'BM', 'EXT', 'CFG', 'URI', 'RTR', 'OUT', 'IN');
Derek Allard15dcf492008-05-12 21:37:04 +000094
Derek Jones0ea06fd2008-02-05 15:23:51 +000095 // Unset globals for security.
Rick Ellisbb2041d2007-06-09 00:16:13 +000096 // This is effectively the same as register_globals = off
Derek Jones0ea06fd2008-02-05 15:23:51 +000097 foreach (array($_GET, $_POST, $_COOKIE, $_SERVER, $_FILES, $_ENV, (isset($_SESSION) && is_array($_SESSION)) ? $_SESSION : array()) as $global)
Derek Allarda72b60d2007-01-31 23:56:11 +000098 {
Derek Jones0b59f272008-05-13 04:22:33 +000099 if ( ! is_array($global))
Derek Allarda72b60d2007-01-31 23:56:11 +0000100 {
Derek Jones0b59f272008-05-13 04:22:33 +0000101 if ( ! in_array($global, $protected))
paulburdick8816aaa2007-06-27 23:07:36 +0000102 {
Derek Jones0ea06fd2008-02-05 15:23:51 +0000103 unset($GLOBALS[$global]);
paulburdick8816aaa2007-06-27 23:07:36 +0000104 }
Derek Allarda72b60d2007-01-31 23:56:11 +0000105 }
106 else
107 {
108 foreach ($global as $key => $val)
109 {
Derek Jones0b59f272008-05-13 04:22:33 +0000110 if ( ! in_array($key, $protected))
paulburdick8816aaa2007-06-27 23:07:36 +0000111 {
Derek Jones0ea06fd2008-02-05 15:23:51 +0000112 unset($GLOBALS[$key]);
113 }
Derek Allard15dcf492008-05-12 21:37:04 +0000114
Derek Jones0ea06fd2008-02-05 15:23:51 +0000115 if (is_array($val))
116 {
117 foreach($val as $k => $v)
118 {
Derek Jones0b59f272008-05-13 04:22:33 +0000119 if ( ! in_array($k, $protected))
Derek Jones0ea06fd2008-02-05 15:23:51 +0000120 {
121 unset($GLOBALS[$k]);
122 }
123 }
paulburdick8816aaa2007-06-27 23:07:36 +0000124 }
Derek Allard15dcf492008-05-12 21:37:04 +0000125 }
Derek Allarda72b60d2007-01-31 23:56:11 +0000126 }
127 }
128
129 // Is $_GET data allowed? If not we'll set the $_GET to an empty array
130 if ($this->allow_get_array == FALSE)
131 {
132 $_GET = array();
133 }
Rick Ellis112569d2007-02-26 19:19:08 +0000134 else
135 {
136 if (is_array($_GET) AND count($_GET) > 0)
137 {
138 foreach($_GET as $key => $val)
139 {
140 $_GET[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
141 }
142 }
143 }
Derek Allard15dcf492008-05-12 21:37:04 +0000144
Derek Allarda72b60d2007-01-31 23:56:11 +0000145 // Clean $_POST Data
146 if (is_array($_POST) AND count($_POST) > 0)
147 {
148 foreach($_POST as $key => $val)
Derek Allard15dcf492008-05-12 21:37:04 +0000149 {
Derek Allarda72b60d2007-01-31 23:56:11 +0000150 $_POST[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
Derek Allard15dcf492008-05-12 21:37:04 +0000151 }
Derek Allarda72b60d2007-01-31 23:56:11 +0000152 }
Derek Allard15dcf492008-05-12 21:37:04 +0000153
Derek Allarda72b60d2007-01-31 23:56:11 +0000154 // Clean $_COOKIE Data
155 if (is_array($_COOKIE) AND count($_COOKIE) > 0)
156 {
157 foreach($_COOKIE as $key => $val)
Derek Allard15dcf492008-05-12 21:37:04 +0000158 {
Derek Allarda72b60d2007-01-31 23:56:11 +0000159 $_COOKIE[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
Derek Allard15dcf492008-05-12 21:37:04 +0000160 }
Derek Allarda72b60d2007-01-31 23:56:11 +0000161 }
Derek Allard15dcf492008-05-12 21:37:04 +0000162
Derek Allarda72b60d2007-01-31 23:56:11 +0000163 log_message('debug', "Global POST and COOKIE data sanitized");
Derek Allard15dcf492008-05-12 21:37:04 +0000164 }
165
Derek Allarda72b60d2007-01-31 23:56:11 +0000166 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000167
Derek Allarda72b60d2007-01-31 23:56:11 +0000168 /**
169 * Clean Input Data
170 *
171 * This is a helper function. It escapes data and
172 * standardizes newline characters to \n
173 *
174 * @access private
175 * @param string
176 * @return string
Derek Allard15dcf492008-05-12 21:37:04 +0000177 */
Derek Allarda72b60d2007-01-31 23:56:11 +0000178 function _clean_input_data($str)
179 {
180 if (is_array($str))
181 {
182 $new_array = array();
183 foreach ($str as $key => $val)
184 {
185 $new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
186 }
187 return $new_array;
188 }
Derek Allard15dcf492008-05-12 21:37:04 +0000189
Rick Ellisbb2041d2007-06-09 00:16:13 +0000190 // We strip slashes if magic quotes is on to keep things consistent
191 if (get_magic_quotes_gpc())
192 {
193 $str = stripslashes($str);
194 }
Derek Allard15dcf492008-05-12 21:37:04 +0000195
Rick Ellisbb2041d2007-06-09 00:16:13 +0000196 // Should we filter the input data?
Derek Allarda72b60d2007-01-31 23:56:11 +0000197 if ($this->use_xss_clean === TRUE)
198 {
199 $str = $this->xss_clean($str);
200 }
Derek Allard15dcf492008-05-12 21:37:04 +0000201
Derek Allarda72b60d2007-01-31 23:56:11 +0000202 // Standardize newlines
Derek Jones0b59f272008-05-13 04:22:33 +0000203 if (strpos($str, "\r") !== FALSE)
204 {
205 $str = str_replace(array("\r\n", "\r"), "\n", $str);
206 }
207
208 return $str;
Derek Allarda72b60d2007-01-31 23:56:11 +0000209 }
Derek Allard15dcf492008-05-12 21:37:04 +0000210
Derek Allarda72b60d2007-01-31 23:56:11 +0000211 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000212
Derek Allarda72b60d2007-01-31 23:56:11 +0000213 /**
214 * Clean Keys
215 *
216 * This is a helper function. To prevent malicious users
217 * from trying to exploit keys we make sure that keys are
218 * only named with alpha-numeric text and a few other items.
219 *
220 * @access private
221 * @param string
222 * @return string
223 */
224 function _clean_input_keys($str)
Derek Allard15dcf492008-05-12 21:37:04 +0000225 {
Derek Jones0b59f272008-05-13 04:22:33 +0000226 if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
Derek Allarda72b60d2007-01-31 23:56:11 +0000227 {
228 exit('Disallowed Key Characters.');
229 }
Rick Ellisbb2041d2007-06-09 00:16:13 +0000230
Derek Allarda72b60d2007-01-31 23:56:11 +0000231 return $str;
232 }
Rick Ellis112569d2007-02-26 19:19:08 +0000233
234 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000235
Rick Ellis112569d2007-02-26 19:19:08 +0000236 /**
237 * Fetch an item from the GET array
238 *
239 * @access public
240 * @param string
241 * @param bool
242 * @return string
243 */
Derek Allard87d1eeb2007-03-01 13:20:43 +0000244 function get($index = '', $xss_clean = FALSE)
Derek Allard15dcf492008-05-12 21:37:04 +0000245 {
Derek Jones0b59f272008-05-13 04:22:33 +0000246 if ( ! isset($_GET[$index]))
Rick Ellis112569d2007-02-26 19:19:08 +0000247 {
248 return FALSE;
249 }
250
251 if ($xss_clean === TRUE)
252 {
253 if (is_array($_GET[$index]))
254 {
255 foreach($_GET[$index] as $key => $val)
Derek Allard15dcf492008-05-12 21:37:04 +0000256 {
Rick Ellis112569d2007-02-26 19:19:08 +0000257 $_GET[$index][$key] = $this->xss_clean($val);
258 }
259 }
260 else
261 {
262 return $this->xss_clean($_GET[$index]);
263 }
264 }
265
266 return $_GET[$index];
267 }
Derek Allard15dcf492008-05-12 21:37:04 +0000268
Derek Allarda72b60d2007-01-31 23:56:11 +0000269 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000270
Derek Allarda72b60d2007-01-31 23:56:11 +0000271 /**
272 * Fetch an item from the POST array
273 *
274 * @access public
275 * @param string
276 * @param bool
277 * @return string
278 */
279 function post($index = '', $xss_clean = FALSE)
Derek Allard15dcf492008-05-12 21:37:04 +0000280 {
Derek Jones0b59f272008-05-13 04:22:33 +0000281 if ( ! isset($_POST[$index]))
Derek Allarda72b60d2007-01-31 23:56:11 +0000282 {
283 return FALSE;
284 }
285
286 if ($xss_clean === TRUE)
287 {
288 if (is_array($_POST[$index]))
289 {
290 foreach($_POST[$index] as $key => $val)
Derek Allard15dcf492008-05-12 21:37:04 +0000291 {
Derek Allarda72b60d2007-01-31 23:56:11 +0000292 $_POST[$index][$key] = $this->xss_clean($val);
293 }
294 }
295 else
296 {
297 return $this->xss_clean($_POST[$index]);
298 }
299 }
300
301 return $_POST[$index];
302 }
Derek Allard15dcf492008-05-12 21:37:04 +0000303
Derek Allarda72b60d2007-01-31 23:56:11 +0000304 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000305
Derek Allarda72b60d2007-01-31 23:56:11 +0000306 /**
307 * Fetch an item from the COOKIE array
308 *
309 * @access public
310 * @param string
311 * @param bool
312 * @return string
313 */
314 function cookie($index = '', $xss_clean = FALSE)
315 {
Derek Jones0b59f272008-05-13 04:22:33 +0000316 if ( ! isset($_COOKIE[$index]))
Derek Allarda72b60d2007-01-31 23:56:11 +0000317 {
318 return FALSE;
319 }
320
321 if ($xss_clean === TRUE)
322 {
323 if (is_array($_COOKIE[$index]))
324 {
325 $cookie = array();
326 foreach($_COOKIE[$index] as $key => $val)
327 {
328 $cookie[$key] = $this->xss_clean($val);
329 }
Derek Allard15dcf492008-05-12 21:37:04 +0000330
Derek Allarda72b60d2007-01-31 23:56:11 +0000331 return $cookie;
332 }
333 else
334 {
335 return $this->xss_clean($_COOKIE[$index]);
336 }
337 }
338 else
339 {
340 return $_COOKIE[$index];
341 }
342 }
343
344 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000345
Derek Allarda72b60d2007-01-31 23:56:11 +0000346 /**
347 * Fetch an item from the SERVER array
348 *
349 * @access public
350 * @param string
351 * @param bool
352 * @return string
353 */
354 function server($index = '', $xss_clean = FALSE)
Derek Allard15dcf492008-05-12 21:37:04 +0000355 {
Derek Jones0b59f272008-05-13 04:22:33 +0000356 if ( ! isset($_SERVER[$index]))
Derek Allarda72b60d2007-01-31 23:56:11 +0000357 {
358 return FALSE;
359 }
360
361 if ($xss_clean === TRUE)
362 {
363 return $this->xss_clean($_SERVER[$index]);
364 }
Derek Allard15dcf492008-05-12 21:37:04 +0000365
Derek Allarda72b60d2007-01-31 23:56:11 +0000366 return $_SERVER[$index];
367 }
Derek Allard15dcf492008-05-12 21:37:04 +0000368
Derek Allarda72b60d2007-01-31 23:56:11 +0000369 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000370
Derek Allarda72b60d2007-01-31 23:56:11 +0000371 /**
372 * Fetch the IP Address
373 *
374 * @access public
375 * @return string
376 */
377 function ip_address()
378 {
379 if ($this->ip_address !== FALSE)
380 {
381 return $this->ip_address;
382 }
Derek Allard15dcf492008-05-12 21:37:04 +0000383
Derek Allarda72b60d2007-01-31 23:56:11 +0000384 if ($this->server('REMOTE_ADDR') AND $this->server('HTTP_CLIENT_IP'))
385 {
386 $this->ip_address = $_SERVER['HTTP_CLIENT_IP'];
387 }
388 elseif ($this->server('REMOTE_ADDR'))
389 {
390 $this->ip_address = $_SERVER['REMOTE_ADDR'];
391 }
392 elseif ($this->server('HTTP_CLIENT_IP'))
393 {
394 $this->ip_address = $_SERVER['HTTP_CLIENT_IP'];
395 }
396 elseif ($this->server('HTTP_X_FORWARDED_FOR'))
397 {
398 $this->ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
399 }
Derek Allard15dcf492008-05-12 21:37:04 +0000400
Derek Allarda72b60d2007-01-31 23:56:11 +0000401 if ($this->ip_address === FALSE)
402 {
403 $this->ip_address = '0.0.0.0';
404 return $this->ip_address;
405 }
Derek Allard15dcf492008-05-12 21:37:04 +0000406
Derek Allarda72b60d2007-01-31 23:56:11 +0000407 if (strstr($this->ip_address, ','))
408 {
409 $x = explode(',', $this->ip_address);
410 $this->ip_address = end($x);
411 }
Derek Allard15dcf492008-05-12 21:37:04 +0000412
Derek Jones0b59f272008-05-13 04:22:33 +0000413 if ( ! $this->valid_ip($this->ip_address))
Derek Allarda72b60d2007-01-31 23:56:11 +0000414 {
415 $this->ip_address = '0.0.0.0';
416 }
Derek Allard15dcf492008-05-12 21:37:04 +0000417
Derek Allarda72b60d2007-01-31 23:56:11 +0000418 return $this->ip_address;
419 }
Derek Allard15dcf492008-05-12 21:37:04 +0000420
Derek Allarda72b60d2007-01-31 23:56:11 +0000421 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000422
Derek Allarda72b60d2007-01-31 23:56:11 +0000423 /**
424 * Validate IP Address
425 *
Rick Ellise666afc2007-06-11 05:03:11 +0000426 * Updated version suggested by Geert De Deckere
427 *
Derek Allarda72b60d2007-01-31 23:56:11 +0000428 * @access public
429 * @param string
430 * @return string
431 */
432 function valid_ip($ip)
433 {
Rick Ellise666afc2007-06-11 05:03:11 +0000434 $ip_segments = explode('.', $ip);
Derek Allard15dcf492008-05-12 21:37:04 +0000435
Rick Ellise666afc2007-06-11 05:03:11 +0000436 // Always 4 segments needed
437 if (count($ip_segments) != 4)
Rick Ellis112569d2007-02-26 19:19:08 +0000438 {
439 return FALSE;
440 }
Rick Ellis65e8f0e2007-06-12 03:53:21 +0000441 // IP can not start with 0
Rick Ellis39213142007-06-12 03:53:12 +0000442 if (substr($ip_segments[0], 0, 1) == '0')
Rick Ellis112569d2007-02-26 19:19:08 +0000443 {
Rick Ellise666afc2007-06-11 05:03:11 +0000444 return FALSE;
445 }
446 // Check each segment
447 foreach ($ip_segments as $segment)
448 {
449 // IP segments must be digits and can not be
450 // longer than 3 digits or greater then 255
Rick Ellisba648932007-06-12 03:39:38 +0000451 if (preg_match("/[^0-9]/", $segment) OR $segment > 255 OR strlen($segment) > 3)
Rick Ellis112569d2007-02-26 19:19:08 +0000452 {
Rick Ellise666afc2007-06-11 05:03:11 +0000453 return FALSE;
Rick Ellis112569d2007-02-26 19:19:08 +0000454 }
455 }
Derek Allard15dcf492008-05-12 21:37:04 +0000456
Rick Ellis112569d2007-02-26 19:19:08 +0000457 return TRUE;
Derek Allarda72b60d2007-01-31 23:56:11 +0000458 }
Derek Allard15dcf492008-05-12 21:37:04 +0000459
Derek Allarda72b60d2007-01-31 23:56:11 +0000460 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000461
Derek Allarda72b60d2007-01-31 23:56:11 +0000462 /**
463 * User Agent
464 *
465 * @access public
466 * @return string
467 */
468 function user_agent()
469 {
470 if ($this->user_agent !== FALSE)
471 {
472 return $this->user_agent;
473 }
Derek Allard15dcf492008-05-12 21:37:04 +0000474
Derek Jones0b59f272008-05-13 04:22:33 +0000475 $this->user_agent = ( ! isset($_SERVER['HTTP_USER_AGENT'])) ? FALSE : $_SERVER['HTTP_USER_AGENT'];
Derek Allard15dcf492008-05-12 21:37:04 +0000476
Derek Allarda72b60d2007-01-31 23:56:11 +0000477 return $this->user_agent;
478 }
Derek Allard15dcf492008-05-12 21:37:04 +0000479
Derek Allarda72b60d2007-01-31 23:56:11 +0000480 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000481
Derek Allarda72b60d2007-01-31 23:56:11 +0000482 /**
paulburdick763064b2007-06-27 23:25:55 +0000483 * Filename Security
484 *
485 * @access public
486 * @param string
487 * @return string
488 */
489 function filename_security($str)
490 {
491 $bad = array(
492 "../",
493 "./",
494 "<!--",
495 "-->",
496 "<",
497 ">",
498 "'",
499 '"',
500 '&',
501 '$',
502 '#',
503 '{',
504 '}',
505 '[',
506 ']',
507 '=',
508 ';',
509 '?',
paulburdick763064b2007-06-27 23:25:55 +0000510 "%20",
511 "%22",
512 "%3c", // <
513 "%253c", // <
514 "%3e", // >
515 "%0e", // >
516 "%28", // (
517 "%29", // )
518 "%2528", // (
519 "%26", // &
520 "%24", // $
521 "%3f", // ?
522 "%3b", // ;
523 "%3d" // =
Derek Allard15dcf492008-05-12 21:37:04 +0000524 );
525
526 return stripslashes(str_replace($bad, '', $str));
paulburdick763064b2007-06-27 23:25:55 +0000527 }
Derek Allard15dcf492008-05-12 21:37:04 +0000528
paulburdick763064b2007-06-27 23:25:55 +0000529 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000530
paulburdick763064b2007-06-27 23:25:55 +0000531 /**
Derek Allarda72b60d2007-01-31 23:56:11 +0000532 * XSS Clean
533 *
534 * Sanitizes data so that Cross Site Scripting Hacks can be
535 * prevented.  This function does a fair amount of work but
536 * it is extremely thorough, designed to prevent even the
537 * most obscure XSS attempts.  Nothing is ever 100% foolproof,
538 * of course, but I haven't been able to get anything passed
539 * the filter.
540 *
541 * Note: This function should only be used to deal with data
542 * upon submission.  It's not something that should
543 * be used for general runtime processing.
544 *
545 * This function was based in part on some code and ideas I
546 * got from Bitflux: http://blog.bitflux.ch/wiki/XSS_Prevention
547 *
548 * To help develop this script I used this great list of
549 * vulnerabilities along with a few other hacks I've
550 * harvested from examining vulnerabilities in other programs:
551 * http://ha.ckers.org/xss.html
552 *
553 * @access public
554 * @param string
555 * @return string
556 */
Derek Jones63fc5fe2008-05-15 20:13:14 +0000557 function xss_clean($str, $is_image = FALSE, $loops = 0)
Derek Jones53437de2008-05-12 18:07:08 +0000558 {
559 /*
560 * Is the string an array?
561 *
562 */
563 if (is_array($str))
564 {
565 while (list($key) = each($str))
566 {
567 $str[$key] = $this->xss_clean($str[$key]);
568 }
Derek Allard15dcf492008-05-12 21:37:04 +0000569
Derek Jones53437de2008-05-12 18:07:08 +0000570 return $str;
571 }
Derek Jones63fc5fe2008-05-15 20:13:14 +0000572
573 /*
574 * Runaway loop prevention. If the text has had to be examined this many times
575 * I think it's safe to say that it is best to simply ignore it.
576 */
577 if ($loops > 9)
578 {
579 return '';
580 }
Derek Allard15dcf492008-05-12 21:37:04 +0000581
Derek Allarda72b60d2007-01-31 23:56:11 +0000582 /*
583 * Remove Null Characters
584 *
585 * This prevents sandwiching null characters
586 * between ascii characters, like Java\0script.
587 *
588 */
589 $str = preg_replace('/\0+/', '', $str);
590 $str = preg_replace('/(\\\\0)+/', '', $str);
591
592 /*
Derek Jones53437de2008-05-12 18:07:08 +0000593 * Protect GET variables in URLs
594 */
595
596 // 901119URL5918AMP18930PROTECT8198
597
598 $str = preg_replace('|\&([a-z\_0-9]+)\=([a-z\_0-9]+)|i', $this->xss_hash()."\\1=\\2", $str);
599
600 /*
Derek Allarda72b60d2007-01-31 23:56:11 +0000601 * Validate standard character entities
602 *
603 * Add a semicolon if missing. We do this to enable
604 * the conversion of entities to ASCII later.
605 *
606 */
Derek Jones48bb32a2007-07-12 13:10:42 +0000607 $str = preg_replace('#(&\#?[0-9a-z]+)[\x00-\x20]*;?#i', "\\1;", $str);
Derek Allard15dcf492008-05-12 21:37:04 +0000608
Derek Allarda72b60d2007-01-31 23:56:11 +0000609 /*
Derek Jones48bb32a2007-07-12 13:10:42 +0000610 * Validate UTF16 two byte encoding (x00)
Derek Allarda72b60d2007-01-31 23:56:11 +0000611 *
612 * Just as above, adds a semicolon if missing.
613 *
614 */
Derek Jones48bb32a2007-07-12 13:10:42 +0000615 $str = preg_replace('#(&\#x?)([0-9A-F]+);?#i',"\\1\\2;",$str);
Derek Allarda72b60d2007-01-31 23:56:11 +0000616
617 /*
Derek Jones53437de2008-05-12 18:07:08 +0000618 * Un-Protect GET variables in URLs
619 */
Derek Jones53437de2008-05-12 18:07:08 +0000620 $str = str_replace($this->xss_hash(), '&', $str);
Derek Allard15dcf492008-05-12 21:37:04 +0000621
Derek Jones53437de2008-05-12 18:07:08 +0000622 /*
Derek Allarda72b60d2007-01-31 23:56:11 +0000623 * URL Decode
624 *
625 * Just in case stuff like this is submitted:
626 *
627 * <a href="http://%77%77%77%2E%67%6F%6F%67%6C%65%2E%63%6F%6D">Google</a>
628 *
Derek Jonesab32a422008-02-04 22:02:11 +0000629 * Note: Use rawurldecode() so it does not remove plus signs
Derek Allarda72b60d2007-01-31 23:56:11 +0000630 *
Derek Allard15dcf492008-05-12 21:37:04 +0000631 */
Derek Jonesab32a422008-02-04 22:02:11 +0000632 $str = rawurldecode($str);
Derek Jones63fc5fe2008-05-15 20:13:14 +0000633
Derek Allarda72b60d2007-01-31 23:56:11 +0000634 /*
Derek Jones303c9cb2007-07-12 19:12:37 +0000635 * Convert character entities to ASCII
Derek Allarda72b60d2007-01-31 23:56:11 +0000636 *
637 * This permits our tests below to work reliably.
638 * We only convert entities that are within tags since
639 * these are the ones that will pose security problems.
640 *
641 */
Derek Allard15dcf492008-05-12 21:37:04 +0000642
Derek Jones303c9cb2007-07-12 19:12:37 +0000643 $str = preg_replace_callback("/[a-z]+=([\'\"]).*?\\1/si", array($this, '_attribute_conversion'), $str);
644
Derek Jones63fc5fe2008-05-15 20:13:14 +0000645 $str = preg_replace_callback("/<\w+.*?(?=>|<|$)/si", array($this, '_html_entity_decode_callback'), $str);
Derek Allard15dcf492008-05-12 21:37:04 +0000646
Derek Jones48bb32a2007-07-12 13:10:42 +0000647 /*
648 * Convert all tabs to spaces
649 *
650 * This prevents strings like this: ja vascript
651 * NOTE: we deal with spaces between characters later.
652 * NOTE: preg_replace was found to be amazingly slow here on large blocks of data,
653 * so we use str_replace.
654 *
655 */
Derek Allard15dcf492008-05-12 21:37:04 +0000656
Derek Jones0b59f272008-05-13 04:22:33 +0000657 if (strpos($str, "\t") !== FALSE)
658 {
659 $str = str_replace("\t", ' ', $str);
Derek Allard15dcf492008-05-12 21:37:04 +0000660 }
Derek Jones48bb32a2007-07-12 13:10:42 +0000661
Derek Jones63fc5fe2008-05-15 20:13:14 +0000662 // capture for comparison at the end
663 $converted_string = $str;
664
Derek Allarda72b60d2007-01-31 23:56:11 +0000665 /*
666 * Not Allowed Under Any Conditions
Derek Allard15dcf492008-05-12 21:37:04 +0000667 */
Derek Jonese3332b02008-05-13 14:44:32 +0000668
669 foreach ($this->never_allowed_str as $key => $val)
Derek Jones48bb32a2007-07-12 13:10:42 +0000670 {
671 $str = str_replace($key, $val, $str);
672 }
Derek Jonese3332b02008-05-13 14:44:32 +0000673
674 foreach ($this->never_allowed_regex as $key => $val)
Derek Allarda72b60d2007-01-31 23:56:11 +0000675 {
676 $str = preg_replace("#".$key."#i", $val, $str);
677 }
Derek Allard15dcf492008-05-12 21:37:04 +0000678
Derek Allarda72b60d2007-01-31 23:56:11 +0000679 /*
Derek Allarda72b60d2007-01-31 23:56:11 +0000680 * Makes PHP tags safe
681 *
682 * Note: XML tags are inadvertently replaced too:
683 *
684 * <?xml
685 *
686 * But it doesn't seem to pose a problem.
687 *
Derek Allard15dcf492008-05-12 21:37:04 +0000688 */
Derek Jones48bb32a2007-07-12 13:10:42 +0000689 $str = str_replace(array('<?php', '<?PHP', '<?', '?'.'>'), array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
Derek Allard15dcf492008-05-12 21:37:04 +0000690
Derek Allarda72b60d2007-01-31 23:56:11 +0000691 /*
692 * Compact any exploded words
693 *
694 * This corrects words like: j a v a s c r i p t
695 * These words are compacted back to their correct state.
696 *
Derek Allard15dcf492008-05-12 21:37:04 +0000697 */
paulburdickb614d392007-06-26 21:58:56 +0000698 $words = array('javascript', 'expression', 'vbscript', 'script', 'applet', 'alert', 'document', 'write', 'cookie', 'window');
Derek Allarda72b60d2007-01-31 23:56:11 +0000699 foreach ($words as $word)
700 {
701 $temp = '';
702 for ($i = 0; $i < strlen($word); $i++)
703 {
704 $temp .= substr($word, $i, 1)."\s*";
705 }
Derek Allard15dcf492008-05-12 21:37:04 +0000706
Derek Jones01f72ca2007-05-04 18:19:17 +0000707 // We only want to do this when it is followed by a non-word character
708 // That way valid stuff like "dealer to" does not become "dealerto"
709 $str = preg_replace('#('.substr($temp, 0, -3).')(\W)#ise', "preg_replace('/\s+/s', '', '\\1').'\\2'", $str);
Derek Allarda72b60d2007-01-31 23:56:11 +0000710 }
Derek Allard15dcf492008-05-12 21:37:04 +0000711
Derek Allarda72b60d2007-01-31 23:56:11 +0000712 /*
713 * Remove disallowed Javascript in links or img tags
paulburdick391eb032007-06-27 22:58:24 +0000714 */
715 do
716 {
717 $original = $str;
Derek Allard15dcf492008-05-12 21:37:04 +0000718
Derek Jones48bb32a2007-07-12 13:10:42 +0000719 if ((version_compare(PHP_VERSION, '5.0', '>=') === TRUE && stripos($str, '</a>') !== FALSE) OR
720 preg_match("/<\/a>/i", $str))
721 {
722 $str = preg_replace_callback("#<a.*?</a>#si", array($this, '_js_link_removal'), $str);
723 }
Derek Allard15dcf492008-05-12 21:37:04 +0000724
Derek Jones48bb32a2007-07-12 13:10:42 +0000725 if ((version_compare(PHP_VERSION, '5.0', '>=') === TRUE && stripos($str, '<img') !== FALSE) OR
726 preg_match("/img/i", $str))
727 {
728 $str = preg_replace_callback("#<img.*?".">#si", array($this, '_js_img_removal'), $str);
729 }
Derek Allard15dcf492008-05-12 21:37:04 +0000730
Derek Jones48bb32a2007-07-12 13:10:42 +0000731 if ((version_compare(PHP_VERSION, '5.0', '>=') === TRUE && (stripos($str, 'script') !== FALSE OR stripos($str, 'xss') !== FALSE)) OR
732 preg_match("/(script|xss)/i", $str))
733 {
734 $str = preg_replace("#</*(script|xss).*?\>#si", "", $str);
735 }
paulburdick391eb032007-06-27 22:58:24 +0000736 }
737 while($original != $str);
Derek Allard15dcf492008-05-12 21:37:04 +0000738
paulburdick391eb032007-06-27 22:58:24 +0000739 unset($original);
Derek Allarda72b60d2007-01-31 23:56:11 +0000740
741 /*
742 * Remove JavaScript Event Handlers
743 *
744 * Note: This code is a little blunt. It removes
745 * the event handler and anything up to the closing >,
746 * but it's unlikely to be a problem.
747 *
Derek Allard15dcf492008-05-12 21:37:04 +0000748 */
Derek Jones01f72ca2007-05-04 18:19:17 +0000749 $event_handlers = array('onblur','onchange','onclick','onfocus','onload','onmouseover','onmouseup','onmousedown','onselect','onsubmit','onunload','onkeypress','onkeydown','onkeyup','onresize', 'xmlns');
Derek Jones245038d2008-05-15 21:58:07 +0000750
751 if ($is_image === TRUE)
752 {
753 /*
754 * Adobe Photoshop puts XML metadata into JFIF images, including namespacing,
755 * so we have to allow this for images. -Paul
756 */
757 unset($event_handlers[array_search('xmlns', $event_handlers)]);
758 }
759
Derek Jones01f72ca2007-05-04 18:19:17 +0000760 $str = preg_replace("#<([^>]+)(".implode('|', $event_handlers).")([^>]*)>#iU", "&lt;\\1\\2\\3&gt;", $str);
Derek Allard15dcf492008-05-12 21:37:04 +0000761
Derek Allarda72b60d2007-01-31 23:56:11 +0000762 /*
763 * Sanitize naughty HTML elements
764 *
765 * If a tag containing any of the words in the list
766 * below is found, the tag gets converted to entities.
767 *
768 * So this: <blink>
769 * Becomes: &lt;blink&gt;
770 *
Derek Allard15dcf492008-05-12 21:37:04 +0000771 */
Derek Jonese3332b02008-05-13 14:44:32 +0000772 $naughty = 'alert|applet|basefont|base|behavior|bgsound|blink|body|embed|expression|form|frameset|frame|head|html|ilayer|iframe|input|layer|link|meta|object|plaintext|style|script|textarea|title|xml|xss';
773 $str = preg_replace_callback('#<(/*\s*)('.$naughty.')([^><]*)([><]*)#is', array($this, '_sanitize_naughty_html'), $str);
Derek Allard15dcf492008-05-12 21:37:04 +0000774
Derek Allarda72b60d2007-01-31 23:56:11 +0000775 /*
776 * Sanitize naughty scripting elements
777 *
778 * Similar to above, only instead of looking for
779 * tags it looks for PHP and JavaScript commands
780 * that are disallowed. Rather than removing the
781 * code, it simply converts the parenthesis to entities
782 * rendering the code un-executable.
783 *
784 * For example: eval('some code')
785 * Becomes: eval&#40;'some code'&#41;
786 *
787 */
paulburdick033ef022007-06-26 21:52:52 +0000788 $str = preg_replace('#(alert|cmd|passthru|eval|exec|expression|system|fopen|fsockopen|file|file_get_contents|readfile|unlink)(\s*)\((.*?)\)#si', "\\1\\2&#40;\\3&#41;", $str);
Derek Allard15dcf492008-05-12 21:37:04 +0000789
Derek Allarda72b60d2007-01-31 23:56:11 +0000790 /*
791 * Final clean up
792 *
793 * This adds a bit of extra precaution in case
794 * something got through the above filters
795 *
Derek Allard15dcf492008-05-12 21:37:04 +0000796 */
Derek Jones000ab692008-05-13 14:46:38 +0000797 foreach ($this->never_allowed_str as $key => $val)
Derek Allarda72b60d2007-01-31 23:56:11 +0000798 {
Derek Jones48bb32a2007-07-12 13:10:42 +0000799 $str = str_replace($key, $val, $str);
800 }
Derek Jones000ab692008-05-13 14:46:38 +0000801
802 foreach ($this->never_allowed_regex as $key => $val)
Derek Jones48bb32a2007-07-12 13:10:42 +0000803 {
Derek Jones63fc5fe2008-05-15 20:13:14 +0000804 $str = preg_replace("#".$key."#i", $val, $str);
Derek Allarda72b60d2007-01-31 23:56:11 +0000805 }
Derek Allard15dcf492008-05-12 21:37:04 +0000806
Derek Jones63fc5fe2008-05-15 20:13:14 +0000807 /*
808 * Images are Handled in a Special Way
809 * - Essentially, we want to know that after all of the character conversion is done whether
810 * any unwanted, likely XSS, code was found. If not, we return TRUE, as the image is clean.
811 * However, if the string post-conversion does not matched the string post-removal of XSS,
812 * then it fails, as there was unwanted XSS code found and removed/changed during processing.
813 */
Derek Allard15dcf492008-05-12 21:37:04 +0000814
Derek Jones63fc5fe2008-05-15 20:13:14 +0000815 if ($is_image === TRUE)
816 {
817 if ($str == $converted_string)
818 {
819 return TRUE;
820 }
821 else
822 {
823 return FALSE;
824 }
825 }
826
827 /*
828 * If something changed after character conversion, we can be fairly confident that something
829 * malicious was removed, so let's take no chances that the attacker is counting on specific
830 * mutations taking place to allow a new attack to reveal itself. So say we all.
831 */
832 if ($converted_string != $str)
833 {
834 $str = $this->xss_clean($str, $is_image, ++$loops);
835 }
836
Derek Allarda72b60d2007-01-31 23:56:11 +0000837 log_message('debug', "XSS Filtering completed");
838 return $str;
839 }
840
841 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000842
Derek Jones01f72ca2007-05-04 18:19:17 +0000843 /**
Derek Jones53437de2008-05-12 18:07:08 +0000844 * Random Hash for protecting URLs
845 *
846 * @access public
847 * @return string
848 */
849 function xss_hash()
Derek Allard15dcf492008-05-12 21:37:04 +0000850 {
Derek Jones53437de2008-05-12 18:07:08 +0000851 if ($this->xss_hash == '')
852 {
853 if (phpversion() >= 4.2)
854 mt_srand();
855 else
856 mt_srand(hexdec(substr(md5(microtime()), -8)) & 0x7fffffff);
Derek Allard15dcf492008-05-12 21:37:04 +0000857
Derek Jones53437de2008-05-12 18:07:08 +0000858 $this->xss_hash = md5(time() + mt_rand(0, 1999999999));
859 }
Derek Allard15dcf492008-05-12 21:37:04 +0000860
Derek Jones53437de2008-05-12 18:07:08 +0000861 return $this->xss_hash;
862 }
863
864 // --------------------------------------------------------------------
Derek Jonese3332b02008-05-13 14:44:32 +0000865
866 /**
867 * Sanitize Naughty HTML
868 *
869 * Callback function for xss_clean() to remove naughty HTML elements
870 *
871 * @access private
872 * @param array
873 * @return string
874 */
875 function _sanitize_naughty_html($matches)
876 {
877 // encode opening brace
878 $str = '&lt;'.$matches[1].$matches[2].$matches[3];
879
880 // encode captured opening or closing brace to prevent recursive vectors
881 if ($matches[4] == '>')
882 {
883 $str .= '&gt;';
884 }
885 elseif ($matches[4] == '<')
886 {
887 $str .= '&lt;';
888 }
Derek Allard15dcf492008-05-12 21:37:04 +0000889
Derek Jonese3332b02008-05-13 14:44:32 +0000890 return $str;
891 }
892
893 // --------------------------------------------------------------------
894
Derek Jones53437de2008-05-12 18:07:08 +0000895 /**
Derek Jones01f72ca2007-05-04 18:19:17 +0000896 * JS Link Removal
897 *
898 * Callback function for xss_clean() to sanitize links
899 * This limits the PCRE backtracks, making it more performance friendly
900 * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in
901 * PHP 5.2+ on link-heavy strings
902 *
903 * @access private
904 * @param array
905 * @return string
906 */
907 function _js_link_removal($match)
908 {
Derek Jones245038d2008-05-15 21:58:07 +0000909 return preg_replace("#<a.+?href=.*?(alert\(|alert&\#40;|javascript\:|window\.|document\.|\.cookie|<script|<xss|base64\s*,|utf\-7\s*,).*?\>.*?</a>#si", "", $match[0]);
Derek Jones01f72ca2007-05-04 18:19:17 +0000910 }
Derek Allard15dcf492008-05-12 21:37:04 +0000911
Derek Jones01f72ca2007-05-04 18:19:17 +0000912 /**
913 * JS Image Removal
914 *
915 * Callback function for xss_clean() to sanitize image tags
916 * This limits the PCRE backtracks, making it more performance friendly
917 * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in
918 * PHP 5.2+ on image tag heavy strings
919 *
920 * @access private
921 * @param array
922 * @return string
923 */
924 function _js_img_removal($match)
925 {
Derek Jones245038d2008-05-15 21:58:07 +0000926 return preg_replace("#<img.+?src=.*?(alert\(|alert&\#40;|javascript\:|window\.|document\.|\.cookie|<script|<xss|base64\s*,|utf-7\s*,).*?\>#si", "", $match[0]);
Derek Jones01f72ca2007-05-04 18:19:17 +0000927 }
Derek Allarda72b60d2007-01-31 23:56:11 +0000928
Derek Jones01f72ca2007-05-04 18:19:17 +0000929 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000930
Derek Jones303c9cb2007-07-12 19:12:37 +0000931 /**
932 * Attribute Conversion
933 *
934 * Used as a callback for XSS Clean
935 *
936 * @access public
937 * @param array
938 * @return string
939 */
940 function _attribute_conversion($match)
941 {
942 return str_replace('>', '&lt;', $match[0]);
943 }
Derek Allard15dcf492008-05-12 21:37:04 +0000944
Derek Jones303c9cb2007-07-12 19:12:37 +0000945 // --------------------------------------------------------------------
946
947 /**
948 * HTML Entity Decode Callback
949 *
950 * Used as a callback for XSS Clean
951 *
952 * @access public
953 * @param array
954 * @return string
955 */
956 function _html_entity_decode_callback($match)
957 {
Derek Jones6159d1d2007-07-16 13:04:46 +0000958 global $CFG;
959 $charset = $CFG->item('charset');
Derek Jones303c9cb2007-07-12 19:12:37 +0000960
961 return $this->_html_entity_decode($match[0], strtoupper($charset));
962 }
963
964 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000965
Derek Allarda72b60d2007-01-31 23:56:11 +0000966 /**
967 * HTML Entities Decode
968 *
969 * This function is a replacement for html_entity_decode()
970 *
971 * In some versions of PHP the native function does not work
972 * when UTF-8 is the specified character set, so this gives us
973 * a work-around. More info here:
974 * http://bugs.php.net/bug.php?id=25670
975 *
976 * @access private
977 * @param string
978 * @param string
979 * @return string
980 */
981 /* -------------------------------------------------
982 /* Replacement for html_entity_decode()
983 /* -------------------------------------------------*/
Derek Allard15dcf492008-05-12 21:37:04 +0000984
Derek Allarda72b60d2007-01-31 23:56:11 +0000985 /*
986 NOTE: html_entity_decode() has a bug in some PHP versions when UTF-8 is the
987 character set, and the PHP developers said they were not back porting the
988 fix to versions other than PHP 5.x.
989 */
Derek Jones303c9cb2007-07-12 19:12:37 +0000990 function _html_entity_decode($str, $charset='UTF-8')
Derek Allarda72b60d2007-01-31 23:56:11 +0000991 {
992 if (stristr($str, '&') === FALSE) return $str;
Derek Allard15dcf492008-05-12 21:37:04 +0000993
Derek Allarda72b60d2007-01-31 23:56:11 +0000994 // The reason we are not using html_entity_decode() by itself is because
995 // while it is not technically correct to leave out the semicolon
996 // at the end of an entity most browsers will still interpret the entity
997 // correctly. html_entity_decode() does not convert entities without
998 // semicolons, so we are left with our own little solution here. Bummer.
Derek Allard15dcf492008-05-12 21:37:04 +0000999
Derek Allarda72b60d2007-01-31 23:56:11 +00001000 if (function_exists('html_entity_decode') && (strtolower($charset) != 'utf-8' OR version_compare(phpversion(), '5.0.0', '>=')))
1001 {
1002 $str = html_entity_decode($str, ENT_COMPAT, $charset);
Derek Jones63fc5fe2008-05-15 20:13:14 +00001003 $str = preg_replace('~&#x(0*[0-9a-f]{2,5})~ei', 'chr(hexdec("\\1"))', $str);
Derek Allarda72b60d2007-01-31 23:56:11 +00001004 return preg_replace('~&#([0-9]{2,4})~e', 'chr(\\1)', $str);
1005 }
Derek Allard15dcf492008-05-12 21:37:04 +00001006
Derek Allarda72b60d2007-01-31 23:56:11 +00001007 // Numeric Entities
Derek Jones63fc5fe2008-05-15 20:13:14 +00001008 $str = preg_replace('~&#x(0*[0-9a-f]{2,5});{0,1}~ei', 'chr(hexdec("\\1"))', $str);
Derek Allarda72b60d2007-01-31 23:56:11 +00001009 $str = preg_replace('~&#([0-9]{2,4});{0,1}~e', 'chr(\\1)', $str);
Derek Allard15dcf492008-05-12 21:37:04 +00001010
Derek Allarda72b60d2007-01-31 23:56:11 +00001011 // Literal Entities - Slightly slow so we do another check
1012 if (stristr($str, '&') === FALSE)
1013 {
1014 $str = strtr($str, array_flip(get_html_translation_table(HTML_ENTITIES)));
1015 }
Derek Allard15dcf492008-05-12 21:37:04 +00001016
Derek Allarda72b60d2007-01-31 23:56:11 +00001017 return $str;
1018 }
1019
1020}
1021// END Input class
Derek Jones53437de2008-05-12 18:07:08 +00001022
1023/* End of file Input.php */
Derek Jonesa3ffbbb2008-05-11 18:18:29 +00001024/* Location: ./system/libraries/Input.php */