Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[hotfix/ZF-10461] Zend_Validator_File #365

Closed
wants to merge 2 commits into from

3 participants

@thomasweidner
  • fixed setting "false" as mimefile
  • fixed Excludemimetype validator to be used in ZF2
thomasweidner added some commits
@thomasweidner thomasweidner Merge branch 'master' of git://github.com/zendframework/zf2 d7438ec
@thomasweidner thomasweidner [hotfix/ZF-10461] Zend_Validator_File
- fixed setting "false" as mimefile
- fixed Excludemimetype validator to be used in ZF2
89ee24a
@weierophinney

tests/Zend/Validator/File/ExcludeMimeTypeTest.php fails on the first data set of testBasic():

PHPUnit 3.5.14 by Sebastian Bergmann.

F...

Time: 0 seconds, Memory: 9.00Mb

There was 1 failure:

1) ZendTest\Validator\File\ExcludeMimeTypeTest::testBasic
Tested with array (
  0 => 'image/gif',
  1 => false,
)
Failed asserting that <boolean:true> matches expected <boolean:false>.

/home/matthew/git/zf2/tests/Zend/Validator/File/ExcludeMimeTypeTest.php:73

FAILURES!
Tests: 4, Assertions: 18, Failures: 1.

This is true for all but the very last data set (array(array('image/jpeg', 'jpeg'), true)).

In debugging this, it appears that finfo is giving back a MIME type of "application/octet-stream" for the file we're testing against (testsize.mo). This is occurring on an Ubuntu 11.04 install running PHP 5.3.5. I've decided to merge anyways, but we may need to do some work on the testbed to ensure these tests will pass for all platforms.

@marcing

Please backport it to ZF 1.11.

Actually the solution here does not seem to be right, it should be as Jarek Nowisz suggested:
http://framework.zend.com/issues/browse/ZF-10461?focusedCommentId=51575#comment-51575

The fix should not require setting the file to "false".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 19, 2011
  1. @thomasweidner
Commits on Aug 29, 2011
  1. @thomasweidner

    [hotfix/ZF-10461] Zend_Validator_File

    thomasweidner authored
    - fixed setting "false" as mimefile
    - fixed Excludemimetype validator to be used in ZF2
This page is out of date. Refresh to see the latest.
View
2  library/Zend/Validator/File/ExcludeMimeType.php
@@ -23,7 +23,7 @@
*/
namespace Zend\Validator\File;
-use Loader;
+use Zend\Loader;
/**
* Validator for the mime type of a file
View
4 library/Zend/Validator/File/MimeType.php
@@ -190,7 +190,9 @@ public function getMagicFile()
*/
public function setMagicFile($file)
{
- if (empty($file)) {
+ if ($file === false) {
+ $this->_magicfile = false;
+ } else if (empty($file)) {
$this->_magicfile = null;
} else if (!(class_exists('finfo', false))) {
$this->_magicfile = null;
Something went wrong with that request. Please try again.