Skip to content

Commit

Permalink
Merge pull request #2 from adhayward/patch-fixboundaryregex
Browse files Browse the repository at this point in the history
Fix boundary identification in getBody
  • Loading branch information
TheTechsTech authored Nov 13, 2019
2 parents 1738691 + 11916fa commit 3c69944
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions decode/MailParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public function getBody(string $returnType = null)
$contentTypeRegex = '/^Content-Type: ?text\/plain/i';

// there could be more than one boundary. This also skips the quotes if they are included.
\preg_match_all('/boundary=(?:|")([a-zA-Z0-9_=\.\(\)_\/+-]+)(?:|")(?:$|;)/mi', $this->raw, $matches);
\preg_match_all('/(*ANYCRLF)boundary=(?:|")([a-zA-Z0-9_=\.\(\)_\/+-]+)(?:|")(?:$|;)/mi', $this->raw, $matches);
$boundaries = $matches[1];
// sometimes boundaries are delimited by quotes - we want to remove them
foreach ($boundaries as $i => $v) {
Expand Down Expand Up @@ -321,7 +321,7 @@ public function getBody(string $returnType = null)

// if the delimited is AAAAA, the line will be --AAAAA - that's why we use substr
if (\is_array($boundaries)) {
if (\in_array(\substr($line, 2), $boundaries)) { // found the delimiter
if (\in_array(\substr($line, 2), $boundaries) || \in_array(\substr($line, 2, -2), $boundaries)) {
break;
}
}
Expand Down

0 comments on commit 3c69944

Please sign in to comment.