Fix CWE-20/CWE-89
This commit is contained in:
parent
328aed5b9a
commit
2b97524972
1 changed files with 3 additions and 65 deletions
|
|
@ -1073,6 +1073,9 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null
|
|||
// Enable this line to know who call the GETPOST with '' $check parameter.
|
||||
//var_dump(getCallerInfoString());
|
||||
}
|
||||
if (in_array($paramname, array('sortfield', 'sortorder'))) { // Force the $check to a more appropriated value
|
||||
$check = 'aZ09comma';
|
||||
}
|
||||
|
||||
if (empty($method)) {
|
||||
$out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] : '');
|
||||
|
|
@ -1264,71 +1267,6 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null
|
|||
|
||||
$out = make_substitutions($out, $substitutionarray, $langs);
|
||||
}
|
||||
|
||||
/* old code
|
||||
$reg = array();
|
||||
$regreplace = array();
|
||||
$maxloop = 20;
|
||||
$loopnb = 0; // Protection against infinite loop
|
||||
|
||||
while (preg_match('/__([A-Z0-9]+(?:_[A-Z0-9]+){0,3})__/i', $out, $reg) && ($loopnb < $maxloop)) { // Detect '__ABCDEF__' as key 'ABCDEF' and '__ABC_DEF__' as key 'ABC_DEF'. Detection is also correct when 2 vars are side by side.
|
||||
$loopnb++;
|
||||
$newout = '';
|
||||
|
||||
if ($reg[1] == 'DAY') {
|
||||
$tmp = dol_getdate(dol_now(), true);
|
||||
$newout = $tmp['mday'];
|
||||
} elseif ($reg[1] == 'MONTH') {
|
||||
$tmp = dol_getdate(dol_now(), true);
|
||||
$newout = $tmp['mon'];
|
||||
} elseif ($reg[1] == 'YEAR') {
|
||||
$tmp = dol_getdate(dol_now(), true);
|
||||
$newout = $tmp['year'];
|
||||
} elseif ($reg[1] == 'PREVIOUS_DAY') {
|
||||
$tmp = dol_getdate(dol_now(), true);
|
||||
$tmp2 = dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']);
|
||||
$newout = $tmp2['day'];
|
||||
} elseif ($reg[1] == 'PREVIOUS_MONTH') {
|
||||
$tmp = dol_getdate(dol_now(), true);
|
||||
$tmp2 = dol_get_prev_month($tmp['mon'], $tmp['year']);
|
||||
$newout = $tmp2['month'];
|
||||
} elseif ($reg[1] == 'PREVIOUS_YEAR') {
|
||||
$tmp = dol_getdate(dol_now(), true);
|
||||
$newout = ($tmp['year'] - 1);
|
||||
} elseif ($reg[1] == 'NEXT_DAY') {
|
||||
$tmp = dol_getdate(dol_now(), true);
|
||||
$tmp2 = dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']);
|
||||
$newout = $tmp2['day'];
|
||||
} elseif ($reg[1] == 'NEXT_MONTH') {
|
||||
$tmp = dol_getdate(dol_now(), true);
|
||||
$tmp2 = dol_get_next_month($tmp['mon'], $tmp['year']);
|
||||
$newout = $tmp2['month'];
|
||||
} elseif ($reg[1] == 'NEXT_YEAR') {
|
||||
$tmp = dol_getdate(dol_now(), true);
|
||||
$newout = ($tmp['year'] + 1);
|
||||
} elseif ($reg[1] == 'MYCOMPANY_COUNTRY_ID' || $reg[1] == 'MYCOUNTRY_ID' || $reg[1] == 'MYCOUNTRYID') {
|
||||
$newout = $mysoc->country_id;
|
||||
} elseif ($reg[1] == 'USER_ID' || $reg[1] == 'USERID') {
|
||||
$newout = $user->id;
|
||||
} elseif ($reg[1] == 'USER_SUPERVISOR_ID' || $reg[1] == 'SUPERVISOR_ID' || $reg[1] == 'SUPERVISORID') {
|
||||
$newout = $user->fk_user;
|
||||
} elseif ($reg[1] == 'ENTITY_ID' || $reg[1] == 'ENTITYID') {
|
||||
$newout = $conf->entity;
|
||||
} elseif ($reg[1] == 'ID') {
|
||||
$newout = '__ID__'; // We keep __ID__ we find into backtopage url
|
||||
} else {
|
||||
$newout = 'REGREPLACE_' . $loopnb; // Key not found, we replace with temporary string to reload later
|
||||
$regreplace[$loopnb] = $reg[0];
|
||||
}
|
||||
//var_dump('__'.$reg[1].'__ -> '.$newout);
|
||||
$out = preg_replace('/__' . preg_quote($reg[1], '/') . '__/', $newout, $out);
|
||||
}
|
||||
if (!empty($regreplace)) {
|
||||
foreach ($regreplace as $key => $value) {
|
||||
$out = preg_replace('/REGREPLACE_' . $key . '/', $value, $out);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// Check type of variable and make sanitization according to this
|
||||
|
|
|
|||
Loading…
Reference in a new issue