Skip to content

Commit

Permalink
Fix a bug where media upload via API are not possible anymore: OpenMa…
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalpianism committed Nov 10, 2020
1 parent 090ea91 commit 23979c4
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/Varien/Io/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,17 @@ public function write($filename, $src, $mode=null)
*/
protected function _IsValidSource($src)
{
//Treat string that contains a null byte as invalid
if ((is_string($src) && strpos($src, chr(0)) === false) || is_resource($src)) {
// In case of a string
if (is_string($src)) {
// If its a file we check for null byte
// If it's not a valid path, file_exists() will return a falsey value, and the @ will keep it from complaining about the bad string.
if (@file_exists($src)
&& strpos($src, chr(0)) !== false) {
return false;
} else {
return true;
}
} elseif (is_resource($src)) {
return true;
}

Expand Down Expand Up @@ -533,7 +542,7 @@ protected function _isFilenameWriteable($filename)
protected function _checkSrcIsFile($src)
{
$result = false;
if (is_string($src) && is_readable($src) && is_file($src)) {
if (is_string($src) && @is_readable($src) && is_file($src)) {
$result = true;
}

Expand Down

0 comments on commit 23979c4

Please sign in to comment.