Check model names for bad characters as well.

This commit is contained in:
mark_story 2017-12-12 13:45:33 -05:00
parent a9618f67f7
commit 340059be15
2 changed files with 8 additions and 1 deletions

View file

@ -1049,10 +1049,14 @@ class Controller extends CakeObject implements CakeEventListener {
$op = '';
}
$allowedChars = '#[^a-zA-Z0-9_ ]#';
$arrayOp = is_array($op);
foreach ($data as $model => $fields) {
if (preg_match($allowedChars, $model)) {
throw new RuntimeException("Unsafe operator found in {$model}");
}
foreach ($fields as $field => $value) {
if (preg_match('#[^a-zA-Z0-9_ ]#', $field)) {
if (preg_match($allowedChars, $field)) {
throw new RuntimeException("Unsafe operator found in {$model}.{$field}");
}
$key = $model . '.' . $field;

View file

@ -1199,6 +1199,9 @@ class ControllerTest extends CakeTestCase {
array(
array('Posts' => array('id IS NULL union all select posts.* from posts where id; --' => 1))
),
array(
array('Post.id IS NULL; --' => array('id' => 1))
),
);
}