Skip to content

Commit

Permalink
Helpers::extractHttpData() skips invalid entry or empty entries
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Aug 28, 2014
1 parent c89d01e commit e8dfd2a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Forms/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static function extractHttpData(array $data, $htmlName, $type)
foreach ($data as $k => $v) {
$data[$k] = $v = static::sanitize($itype, $v);
if ($v === NULL) {
return array();
unset($data[$k]);
}
}
if ($type & Form::DATA_KEYS) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Forms/Controls.ImageButton.loadData.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ test(function() { // missing data
test(function() { // malformed data
$_POST = array(
'malformed1' => array(1),
'malformed2' => array(array(NULL), 'x'),
'malformed2' => array(array(NULL)),
);

$form = new Form;
Expand Down
2 changes: 1 addition & 1 deletion tests/Forms/Helpers.extractHttpData.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ test(function() { // files


Assert::equal(array($file, $file), Helpers::extractHttpData(array(
'multiple' => array('avatar' => array('x' => $file, $file)),
'multiple' => array('avatar' => array('x' => $file, NULL, $file)),
), 'multiple[avatar][]', Form::DATA_FILE));

Assert::equal(array('x' => $file, $file), Helpers::extractHttpData(array(
Expand Down

0 comments on commit e8dfd2a

Please sign in to comment.