diff --git a/src/Header.php b/src/Header.php index d18e98a1..aaa40e35 100644 --- a/src/Header.php +++ b/src/Header.php @@ -193,7 +193,7 @@ public function getBoundary(): ?string { * @return string */ private function clearBoundaryString(string $str): string { - return str_replace(['"', '\r', '\n', "\n", "\r", ";", "\s"], "", $str); + return trim(str_replace(['"', '\r', '\n', "\n", "\r", ";", "\s"], "", $str)); } /** diff --git a/src/Structure.php b/src/Structure.php index 11f4cd66..cd296c49 100644 --- a/src/Structure.php +++ b/src/Structure.php @@ -115,7 +115,7 @@ private function parsePart(string $context, int $part_number = 0): array { if (($boundary = $headers->getBoundary()) !== null) { $parts = $this->detectParts($boundary, $body, $part_number); - if(count($parts) > 1) { + if (count($parts) > 1 || !empty($parts[0]->subtype)) { return $parts; } }