Last active
July 27, 2017 14:25
-
-
Save sanderjongsma/e32bb5fb2a45b4ce45d99cc541203b2d to your computer and use it in GitHub Desktop.
Workaround for accepting PDF uploads in backend Magento after SUPEE-9767 v1/v2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<config> | |
<modules> | |
<Vendor_ExtendedValidator> | |
<version>0.1.0</version> | |
</Vendor_ExtendedValidator> | |
</modules> | |
<global> | |
<models> | |
<vendor_extendedvalidator> | |
<class>Vendor_ExtendedValidator_Model</class> | |
</vendor_extendedvalidator> | |
<core> | |
<rewrite> | |
<file_validator_image>Vendor_ExtendedValidator_Model_File_Validator_Image</file_validator_image> | |
</rewrite> | |
</core> | |
</models> | |
</global> | |
</config> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Created by PhpStorm. | |
* User: sander | |
* Date: 25-7-17 | |
* Time: 10:16 | |
*/ | |
class Vendor_ExtendedValidator_Model_File_Validator_Image extends Mage_Core_Model_File_Validator_Image | |
{ | |
/** | |
* Allowed Mime Content Types | |
* @return array | |
*/ | |
protected function getAllowedMimeContentTypes() | |
{ | |
return ['application/pdf']; | |
} | |
/** | |
* If Mime Content Type is allowed return null, else validate with parent | |
* | |
* @param string $filePath | |
* @return null | |
*/ | |
public function validate($filePath) | |
{ | |
$allowedMimeContentTypes = $this->getAllowedMimeContentTypes(); | |
if (in_array(mime_content_type($filePath), $allowedMimeContentTypes)) { | |
return null; | |
} | |
parent::validate($filePath); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment