Fix injection on fieldname descartes

This commit is contained in:
osaajani 2019-11-04 17:45:16 +01:00
parent 1865072b73
commit 628527c70f
1 changed files with 10 additions and 3 deletions

View File

@ -126,10 +126,11 @@
$values = count($values) ? $values : array();
foreach ($values as $clef => $value)
foreach ($values as $key => $value)
{
$return['PARAMS']['in_value_' . $clef] = $value;
$flags[] = ':in_value_' . $clef;
$key = preg_replace('#[^a-zA-Z0-9_]#', '', $key);
$return['PARAMS']['in_value_' . $key] = $value;
$flags[] = ':in_value_' . $key;
}
$return['QUERY'] .= ' IN(' . implode(', ', $flags) . ')';
@ -191,6 +192,9 @@
$operator = '=';
}
//Protect against injection in fieldname
$true_fieldname = preg_replace('#[^a-zA-Z0-9_]#', '', $true_fieldname);
$query = '`' . $true_fieldname . '` ' . $operator . ' :where_' . $true_fieldname;
$param = ['where_' . $true_fieldname => $value];
@ -328,6 +332,7 @@
foreach ($datas as $label => $value)
{
$label = preg_replace('#[^a-zA-Z0-9_]#', '', $label);
$params['set_' . $label] = $value;
$sets[] = '`' . $label . '` = :set_' . $label . ' ';
}
@ -381,6 +386,8 @@
foreach ($datas as $field_name => $value)
{
//Protect against injection in fieldname
$field_name = preg_replace('#[^a-zA-Z0-9_]#', '', $field_name);
$params[$field_name] = $value;
$field_names[] = $field_name;
}