Skip to content

Commit 3c69944

Browse files
authored
Merge pull request #2 from adhayward/patch-fixboundaryregex
Fix boundary identification in getBody
2 parents 1738691 + 11916fa commit 3c69944

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

decode/MailParser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ public function getBody(string $returnType = null)
285285
$contentTypeRegex = '/^Content-Type: ?text\/plain/i';
286286

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

322322
// if the delimited is AAAAA, the line will be --AAAAA - that's why we use substr
323323
if (\is_array($boundaries)) {
324-
if (\in_array(\substr($line, 2), $boundaries)) { // found the delimiter
324+
if (\in_array(\substr($line, 2), $boundaries) || \in_array(\substr($line, 2, -2), $boundaries)) {
325325
break;
326326
}
327327
}

0 commit comments

Comments
 (0)