From 25fa1a067c670010553799873bab75ad0b866155 Mon Sep 17 00:00:00 2001 From: webklex Date: Wed, 28 Jun 2023 03:46:21 +0200 Subject: [PATCH] Attachment name parsing fixed #410 #421 --- src/Attachment.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Attachment.php b/src/Attachment.php index fcbc54e..85ea62f 100755 --- a/src/Attachment.php +++ b/src/Attachment.php @@ -269,12 +269,10 @@ public function decodeName(?string $name): string { } $decoder = $this->config['decoder']['message']; - if($decoder === 'utf-8' && extension_loaded('imap')) { - $name = \imap_utf8($name); - } - if (preg_match('/=\?([^?]+)\?(Q|B)\?(.+)\?=/i', $name, $matches)) { $name = $this->part->getHeader()->decode($name); + } elseif ($decoder === 'utf-8' && extension_loaded('imap')) { + $name = \imap_utf8($name); } // check if $name is url encoded @@ -284,9 +282,7 @@ public function decodeName(?string $name): string { // sanitize $name // order of '..' is important - $name = str_replace(['\\', '/', chr(0), ':', '..'], '', $name); - - return $name; + return str_replace(['\\', '/', chr(0), ':', '..'], '', $name); } return ""; }