diff --git a/lib/Varien/Io/File.php b/lib/Varien/Io/File.php index 0cf379b33f3..052df5cca65 100644 --- a/lib/Varien/Io/File.php +++ b/lib/Varien/Io/File.php @@ -486,8 +486,12 @@ 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. + return !(@file_exists($src) && strpos($src, chr(0)) !== false); + } elseif (is_resource($src)) { return true; } @@ -533,7 +537,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; }