note 116247 added to function.preg-replace
| From: | thegatekeeper1978 at gmail dot com | Date: | Sun, 30 Nov 2014 07:45:22 +0000 |
| Subject: | note 116247 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-201041@lists.php.net to get a copy of this message | ||
"preg_replace" is able to be exploited with a DOS attack by the user submitting a very
long string. One way I combat this is by using "substr" first to grab the first part of
the string.
$input_string = $_GET['user_input'];
// If necessary you can log any user attempts to submit a long string
$string_length = strlen($input_string);
if($string_lenght > 100){log_func($_SERVER['REMOTE_ADDR'], $string_length,
$input_string);}
$input_string_cut = substr($input_string,0,100);
$string = preg_replace('/[^a-zA-Z0-9]/', '', $input_string_cut);
echo($string);
----
Server IP: 72.52.91.14
Probable Submitter: 174.102.161.183
----
Manual Page -- http://php.net/manual/en/function.preg-replace.php
Edit -- https://master.php.net/note/edit/116247
Del: integrated -- https://master.php.net/note/delete/116247/integrated
Del: useless -- https://master.php.net/note/delete/116247/useless
Del: bad code -- https://master.php.net/note/delete/116247/bad+code
Del: spam -- https://master.php.net/note/delete/116247/spam
Del: non-english -- https://master.php.net/note/delete/116247/non-english
Del: in docs -- https://master.php.net/note/delete/116247/in+docs
Del: other reasons-- https://master.php.net/note/delete/116247
Reject -- https://master.php.net/note/reject/116247
Search -- https://master.php.net/manage/user-notes.php