GETPOST(..., 'alpha') does not accept \ char anymore. Replaced with /
This commit is contained in:
parent
53eb79154a
commit
d9488770ae
3 changed files with 21 additions and 15 deletions
|
|
@ -984,7 +984,7 @@ if (empty($reshook)) {
|
|||
}
|
||||
$i = 0;
|
||||
foreach ($listfieldmodify as $field) {
|
||||
$keycode = $listfieldvalue[$i];
|
||||
$keycode = empty($listfieldvalue[$i]) ? '' : $listfieldvalue[$i];
|
||||
if (empty($keycode)) {
|
||||
$keycode = $field;
|
||||
}
|
||||
|
|
@ -1001,7 +1001,7 @@ if (empty($reshook)) {
|
|||
$sql .= ",";
|
||||
}
|
||||
$sql .= $field."=";
|
||||
if ($listfieldvalue[$i] == 'sortorder') { // For column name 'sortorder', we use the field name 'position'
|
||||
if ($keycode == 'sortorder') { // For column name 'sortorder', we use the field name 'position'
|
||||
$sql .= GETPOSTINT('position');
|
||||
} elseif (GETPOST($keycode) == '' && !($keycode == 'code' && $id == 10)) {
|
||||
$sql .= "null"; // For vat, we want/accept code = ''
|
||||
|
|
|
|||
|
|
@ -671,7 +671,7 @@ function GETPOSTISARRAY($paramname, $method = 0)
|
|||
* 'array', 'array:restricthtml' or 'array:aZ09' to check it's an array
|
||||
* 'int'=check it's numeric (integer or float)
|
||||
* 'intcomma'=check it's integer+comma ('1,2,3,4...')
|
||||
* 'alpha'=Same than alphanohtml since v13
|
||||
* 'alpha'=Same than alphanohtml
|
||||
* 'alphawithlgt'=alpha with lgt
|
||||
* 'alphanohtml'=check there is no html content and no " and no ../
|
||||
* 'aZ'=check it's a-z only
|
||||
|
|
@ -1115,11 +1115,15 @@ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options
|
|||
$oldstringtoclean = $out;
|
||||
// Remove html tags
|
||||
$out = dol_string_nohtmltag($out, 0);
|
||||
// Convert '\' used for windows path into '/' so we can use for path but not for octal syntax \999, hexa syntax \x999 and unicode syntax \u{999}
|
||||
$out = str_ireplace('\\', '/', $out);
|
||||
// Remove also other dangerous string sequences
|
||||
// '"' is dangerous because param in url can close the href= or src= and add javascript functions.
|
||||
// '../' or '..\' is dangerous because it allows dir transversals
|
||||
// Note &, '&', '&'... is a simple char like '&' alone but there is no reason to accept such way to encode input data.
|
||||
$out = str_ireplace(array('&', '&', '&', '"', '"', '"', '"', '"', '/', '/', '\', '\', '/', '../', '..\\'), '', $out);
|
||||
// '&', '&', '&'... is a the char '&' alone but there is no reason to accept such way to encode input char
|
||||
// '"' = '"' = '"' = '"' is dangerous because param in url can close the href= or src= and add javascript functions.
|
||||
// '/', '/', '/' is the char '/' but there is no reason to accept such way to encode this input char
|
||||
// '\' = '\' = '\' is the char '\' but there is no reason to accept such way to encode this input char
|
||||
$out = str_ireplace(array('../', '..\\', '&', '&', '&', '"', '"', '"', '"', '"', '/', '/', '/', '\', '\', '\'), '', $out);
|
||||
} while ($oldstringtoclean != $out);
|
||||
// keep lines feed
|
||||
}
|
||||
|
|
@ -1129,12 +1133,17 @@ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options
|
|||
$out = trim($out);
|
||||
do {
|
||||
$oldstringtoclean = $out;
|
||||
// Remove html tags
|
||||
// Decode html entities
|
||||
$out = dol_html_entity_decode($out, ENT_COMPAT | ENT_HTML5, 'UTF-8');
|
||||
// '"' is dangerous because param in url can close the href= or src= and add javascript functions.
|
||||
// Convert '\' used for windows path into '/' so we can use for path but not for octal syntax \999, hexa syntax \x999 and unicode syntax \u{999}
|
||||
$out = str_ireplace('\\', '/', $out);
|
||||
// Remove also other dangerous string sequences
|
||||
// '../' or '..\' is dangerous because it allows dir transversals
|
||||
// Note &, '&', '&'... is a simple char like '&' alone but there is no reason to accept such way to encode input data.
|
||||
$out = str_ireplace(array('&', '&', '&', '"', '"', '"', '"', '"', '/', '/', '\', '\', '/', '../', '..\\'), '', $out);
|
||||
// '&', '&', '&'... is a the char '&' alone but there is no reason to accept such way to encode input char
|
||||
// '"' = '"' = '"' = '"' is dangerous because param in url can close the href= or src= and add javascript functions.
|
||||
// '/', '/', '/' is the char '/' but there is no reason to accept such way to encode this input char
|
||||
// '\' = '\' = '\' is the char '\' but there is no reason to accept such way to encode this input char
|
||||
$out = str_ireplace(array('../', '..\\', '&', '&', '&', '"', '"', '"', '"', '"', '/', '/', '/', '\', '\', '\'), '', $out);
|
||||
} while ($oldstringtoclean != $out);
|
||||
}
|
||||
break;
|
||||
|
|
@ -1152,9 +1161,6 @@ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options
|
|||
if (empty($filter)) {
|
||||
return 'BadParameterForGETPOST - Param 3 of sanitizeVal()';
|
||||
}
|
||||
/*if (empty($options)) {
|
||||
return 'BadParameterForGETPOST - Param 4 of sanitizeVal()';
|
||||
}*/
|
||||
if (is_null($options)) {
|
||||
$options = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -358,11 +358,11 @@ class SecurityTest extends CommonClassTest
|
|||
|
||||
$result = GETPOST("param2", 'alpha');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, $_GET["param2"], 'Test on param2');
|
||||
$this->assertEquals($result, 'a/b#e(pr)qq-rr/cc', 'Test on param2');
|
||||
|
||||
$result = GETPOST("param3", 'alpha'); // Must return string sanitized from char "
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, 'na/b#e(pr)qq-rr\cc', 'Test on param3');
|
||||
$this->assertEquals($result, 'na/b#e(pr)qq-rr/cc', 'Test on param3');
|
||||
|
||||
$result = GETPOST("param4a", 'alpha'); // Must return string sanitized from ../
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
|
|
|||
Loading…
Reference in a new issue