Changeset 33598
- Timestamp:
- 11/25/12 10:57:29 (7 months ago)
- Files:
-
- branches/1.4/lib/form/sfForm.class.php (modified) (2 diffs)
- branches/1.4/test/unit/form/sfFormTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.4/lib/form/sfForm.class.php
r29678 r33598 223 223 } 224 224 225 $this->checkTaintedValues($this->taintedValues); 226 225 227 try 226 228 { … … 1337 1339 return $array1; 1338 1340 } 1341 1342 /** 1343 * Checks that the $_POST values do not contain something that 1344 * looks like a file upload (coming from $_FILE). 1345 */ 1346 protected function checkTaintedValues($values) 1347 { 1348 foreach ($values as $name => $value) 1349 { 1350 if (!is_array($value)) { 1351 continue; 1352 } 1353 1354 if (isset($value['tmp_name'])) { 1355 throw new InvalidArgumentException('Do not try to fake a file upload.'); 1356 } 1357 1358 $this->checkTaintedValues($value); 1359 } 1360 } 1339 1361 } branches/1.4/test/unit/form/sfFormTest.php
r29678 r33598 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(16 3);13 $t = new lime_test(165); 14 14 15 15 class FormTest extends sfForm … … 980 980 $f->bind(array('5' => 'bound')); 981 981 $t->is_deeply($f->getFormFieldSchema()->getValue(), array('5' => 'bound'), '->getFormFieldSchema() includes bound numeric fields'); 982 983 // bind with a simulated file upload in the POST array 984 $f = new FormTest(); 985 try 986 { 987 $f->bind(array( 988 'file' => array( 989 'name' => 'foo.txt', 990 'type' => 'text/plain', 991 'tmp_name' => 'somefile', 992 'error' => 0, 993 'size' => 10, 994 ), 995 )); 996 $t->fail('Cannot fake a file upload with a POST'); 997 } 998 catch (InvalidArgumentException $e) 999 { 1000 $t->pass('Cannot fake a file upload with a POST'); 1001 } 1002 1003 $f = new FormTest(); 1004 try 1005 { 1006 $f->bind(array( 1007 'foo' => array( 1008 'bar' => array( 1009 'file' => array( 1010 'name' => 'foo.txt', 1011 'type' => 'text/plain', 1012 'tmp_name' => 'somefile', 1013 'error' => 0, 1014 'size' => 10, 1015 ), 1016 ), 1017 ), 1018 )); 1019 $t->fail('Cannot fake a file upload with a POST'); 1020 } 1021 catch (InvalidArgumentException $e) 1022 { 1023 $t->pass('Cannot fake a file upload with a POST'); 1024 }