original EncodeFile uses is_readable. this fails with files stored in vfs in webusers context. use fopen instead, as old function (version 2.1) did

This commit is contained in:
Klaus Leithoff 2010-04-20 10:02:36 +00:00
parent c2413db67b
commit 9284452553

View File

@ -1492,7 +1492,7 @@ class PHPMailer {
*/ */
private function EncodeFile($path, $encoding = 'base64') { private function EncodeFile($path, $encoding = 'base64') {
try { try {
if (!is_readable($path)) { if (!@$fd = fopen($path,'rb')) {
throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE); throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE);
} }
if (function_exists('get_magic_quotes')) { if (function_exists('get_magic_quotes')) {
@ -1505,8 +1505,12 @@ class PHPMailer {
set_magic_quotes_runtime(0); set_magic_quotes_runtime(0);
} }
$file_buffer = file_get_contents($path); $file_buffer = file_get_contents($path);
fclose($fd);
$file_buffer = $this->EncodeString($file_buffer, $encoding); $file_buffer = $this->EncodeString($file_buffer, $encoding);
if (PHP_VERSION < 6) { set_magic_quotes_runtime($magic_quotes); } if (PHP_VERSION < 6)
{
set_magic_quotes_runtime($magic_quotes);
}
return $file_buffer; return $file_buffer;
} catch (Exception $e) { } catch (Exception $e) {
$this->SetError($e->getMessage()); $this->SetError($e->getMessage());