Pārlūkot izejas kodu

[GENERIC] Zend_Validate_File:

- fix new fileinfo extension sending additional infos
  (instead of image/jpeg it sends image/jpeg; charset=binary)

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@17151 44c647ce-9c0f-0410-b52a-842ac1e357ba
thomas 16 gadi atpakaļ
vecāks
revīzija
9b7c3bbe36

+ 6 - 0
library/Zend/Validate/File/MimeType.php

@@ -255,6 +255,12 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract
             return $this->_throw($file, self::NOT_DETECTED);
         }
 
+        // delete additional info
+        $pos = strpos($this->_type, ';');
+        if ($pos !== false) {
+            $this->_type = substr($this->_type, 0, $pos);
+        }
+
         $mimetype = $this->getMimeType(true);
         if (in_array($this->_type, $mimetype)) {
             return true;

+ 3 - 0
tests/Zend/Validate/File/MimeTypeTest.php

@@ -72,6 +72,9 @@ class Zend_Validate_File_MimeTypeTest extends PHPUnit_Framework_TestCase
             array(array('image/vasa', 'image/jpg', 'image/jpeg'), true),
             array(array('image/jpg', 'image/jpeg', 'gif'), true),
             array(array('image/gif', 'gif'), false),
+            array('image/jp', false),
+            array('image/jpg2000', false),
+            array('image/jpeg2000', false),
         );
 
         $filetest = dirname(__FILE__) . '/_files/picture.jpg';