Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/4470'
Browse files Browse the repository at this point in the history
Close #4470
  • Loading branch information
weierophinney committed May 23, 2013
2 parents ada8301 + 970dce7 commit 176a336
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
18 changes: 9 additions & 9 deletions library/Zend/Validator/File/Upload.php
Expand Up @@ -163,40 +163,40 @@ public function isValid($value, $file = null)
switch ($content['error']) {
case 0:
if (!is_uploaded_file($content['tmp_name'])) {
$this->throwError($file, self::ATTACK);
$this->throwError($content, self::ATTACK);
}
break;

case 1:
$this->throwError($file, self::INI_SIZE);
$this->throwError($content, self::INI_SIZE);
break;

case 2:
$this->throwError($file, self::FORM_SIZE);
$this->throwError($content, self::FORM_SIZE);
break;

case 3:
$this->throwError($file, self::PARTIAL);
$this->throwError($content, self::PARTIAL);
break;

case 4:
$this->throwError($file, self::NO_FILE);
$this->throwError($content, self::NO_FILE);
break;

case 6:
$this->throwError($file, self::NO_TMP_DIR);
$this->throwError($content, self::NO_TMP_DIR);
break;

case 7:
$this->throwError($file, self::CANT_WRITE);
$this->throwError($content, self::CANT_WRITE);
break;

case 8:
$this->throwError($file, self::EXTENSION);
$this->throwError($content, self::EXTENSION);
break;

default:
$this->throwError($file, self::UNKNOWN);
$this->throwError($content, self::UNKNOWN);
break;
}
}
Expand Down
26 changes: 26 additions & 0 deletions tests/ZendTest/Validator/File/UploadTest.php
Expand Up @@ -249,4 +249,30 @@ public function testZF11258()
$this->assertTrue(array_key_exists('fileUploadErrorFileNotFound', $validator->getMessages()));
$this->assertContains("nofile.mo'", current($validator->getMessages()));
}

/**
* @group ZF-12128
*/
public function testErrorMessage()
{
$_FILES = array(
'foo' => array(
'name' => 'bar',
'type' => 'text',
'size' => 100,
'tmp_name' => 'tmp_bar',
'error' => 7,
)
);

$validator = new File\Upload;
$validator->isValid('foo');

$this->assertEquals(
array(
'fileUploadErrorCantWrite' => "File 'bar' can't be written",
),
$validator->getMessages()
);
}
}

0 comments on commit 176a336

Please sign in to comment.