forked from Wavyzz/dolibarr
FIX #yogosha9754
This commit is contained in:
@@ -99,6 +99,7 @@ function testSqlAndScriptInject($val, $type)
|
||||
return realCharForNumericEntities($m); }, $val);
|
||||
// We clean html comments because some hacks try to obfuscate evil strings by inserting HTML comments. Example: on<!-- -->error=alert(1)
|
||||
$val = preg_replace('/<!--[^>]*-->/', '', $val);
|
||||
$val = preg_replace('/[\r\n]/', '', $val);
|
||||
} while ($oldval != $val);
|
||||
//print "type = ".$type." after decoding: ".$val."\n";
|
||||
|
||||
@@ -106,7 +107,12 @@ function testSqlAndScriptInject($val, $type)
|
||||
|
||||
// We check string because some hacks try to obfuscate evil strings by inserting non printable chars. Example: 'java(ascci09)scr(ascii00)ipt' is processed like 'javascript' (whatever is place of evil ascii char)
|
||||
// We should use dol_string_nounprintableascii but function is not yet loaded/available
|
||||
$newval = preg_replace('/[\x00-\x1F\x7F]/u', '', $val); // /u operator makes UTF8 valid characters being ignored so are not included into the replace
|
||||
// Example of valid UTF8 chars:
|
||||
// utf8=utf8mb3: '\x0A', '\x0D', '\x7E'
|
||||
// utf8=utf8mb3: '\xE0\xA0\x80'
|
||||
// utf8mb4: '\xF0\x9D\x84\x9E' (but this may be refused by the database insert if pagecode is utf8=utf8mb3)
|
||||
$newval = preg_replace('/[\x00-\x09\x0B-\x0C\x0E-\x1F\x7F]/u', '', $val); // /u operator makes UTF8 valid characters being ignored so are not included into the replace
|
||||
// Note that $newval may also be completely empty '' when non valid UTF8 are found.
|
||||
if ($newval != $val) {
|
||||
// If $val has changed after removing non valid UTF8 chars, it means we have an evil string.
|
||||
$inj += 1;
|
||||
|
||||
Reference in New Issue
Block a user