From 2326fe14d7bc442c0ebd325aa0ffc430e5f0de20 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 27 Aug 2024 07:46:56 +1200 Subject: [PATCH] Ensure headers are strings, not NULL if not set --- src/parser/interfaces/part_parser.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/parser/interfaces/part_parser.php b/src/parser/interfaces/part_parser.php index a81378b3..dfe4c078 100644 --- a/src/parser/interfaces/part_parser.php +++ b/src/parser/interfaces/part_parser.php @@ -168,7 +168,11 @@ static public function createPartParserForHeaders( ezcMailHeadersHolder $headers break; case 'text': - if ( ezcMailPartParser::$parseTextAttachmentsAsFiles === true ) + // dev/core#940 Ensure that emails are not processed as .unknown attachments by checking + // for Filename or name in the content-disposition and content-type headers. + if ( (ezcMailPartParser::$parseTextAttachmentsAsFiles === true) && + (preg_match('/\s*filename="?([^;"]*);?/i', $headers['Content-Disposition'] ?? '') || + preg_match( '/\s*name="?([^;"]*);?/i' , $headers['Content-Type'] ?? '') ) ) { $bodyParser = new ezcMailFileParser( $mainType, $subType, $headers ); }