Skip to content

Commit

Permalink
mailparse: Misc. Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
protich committed Nov 8, 2022
1 parent 46b7899 commit f85f903
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions include/class.mailparse.php
Expand Up @@ -36,16 +36,12 @@ class Mail_Parse {
function __construct(&$mimeMessage, $charset=null){

$this->mime_message = &$mimeMessage;

if($charset)
$this->charset = $charset;

$this->include_bodies = true;
$this->decode_headers = false;
$this->decode_bodies = true;

//Desired charset
if($charset)
if ($charset)
$this->charset = $charset;

$this->splitBodyHeader();
Expand Down Expand Up @@ -213,7 +209,7 @@ static function findHeaderEntry($headers, $name, $allEntries=false) {

function getHeaderEntry($name) {
return $this->hasHeaders()
? self::findHeaderEntry($this->headers, $name)
? self::findHeaderEntry($this->getHeaders(), $name)
: false;
}

Expand Down Expand Up @@ -763,7 +759,7 @@ class EmailDataParser {
'attachOnParseError' => true
];
private $stream;
private $errors;
private $errors = [];

function __construct($stream=null, array $options = []) {
$this->stream = $stream;
Expand All @@ -783,7 +779,7 @@ function parse($stream) {
}

$parser= new Mail_Parse($contents);
if (1 || !$parser->decode())
if (!$parser->decode())
return $this->onParseError($parser);

if (!($data = $parser->getHeaderInfo()))
Expand Down Expand Up @@ -830,14 +826,18 @@ private function onParseError($parser) {
}

private function err($error) {
$this->errors [] = $error;
return false;
// add error and return false
return ($this->addError($error) && false);
}

function getErrors() {
return $this->errors;
}

function addError($error) {
$this->errors [] = $error;
}

function getError() {
return $this->lastError();
}
Expand Down

0 comments on commit f85f903

Please sign in to comment.