Skip to content

Commit

Permalink
Fix incorrect pattern in SecurityComponent.
Browse files Browse the repository at this point in the history
The test pattern was not catching multi digit numbers.

Refs #6456
  • Loading branch information
markstory committed May 1, 2015
1 parent 6528df6 commit 29c9836
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Controller/Component/SecurityComponent.php
Expand Up @@ -306,7 +306,7 @@ protected function _validatePost(Controller $controller)
$multi = [];

foreach ($fieldList as $i => $key) {
if (preg_match('/(\.\d){1,10}$/', $key)) {
if (preg_match('/(\.\d+){1,10}$/', $key)) {
$multi[$i] = preg_replace('/(\.\d+){1,10}$/', '', $key);
unset($fieldList[$i]);
} else {
Expand Down
6 changes: 6 additions & 0 deletions tests/TestCase/Controller/Component/SecurityComponentTest.php
Expand Up @@ -500,6 +500,12 @@ public function testValidatePostArray()
'_Token' => compact('fields', 'unlocked')
];
$this->assertTrue($this->Controller->Security->validatePost($this->Controller));

$this->Controller->request->data = [
'Model' => ['multi_field' => [12 => '1', 20 => '3']],
'_Token' => compact('fields', 'unlocked')
];
$this->assertTrue($this->Controller->Security->validatePost($this->Controller));
}

/**
Expand Down

0 comments on commit 29c9836

Please sign in to comment.