From 5457dc1212a78be536684cd2fb97de82f9520ce2 Mon Sep 17 00:00:00 2001 From: gitstashgithub Date: Fri, 8 Jul 2022 12:08:57 +1000 Subject: [PATCH] Fix slash in attachment file name issue Some systems allow slash(/) in attachment file name, and it causes issue in IncomingMailAttachment::saveToDisk() function. The \file_put_contents() function cannot handle it and throws error Failed to open stream: No such file or directory --- src/PhpImap/Mailbox.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PhpImap/Mailbox.php b/src/PhpImap/Mailbox.php index 8e1803b9..aafaa4fc 100644 --- a/src/PhpImap/Mailbox.php +++ b/src/PhpImap/Mailbox.php @@ -1348,6 +1348,7 @@ public function downloadAttachment(DataPartInfo $dataInfo, array $params, object $fileName = $this->decodeMimeStr($fileName); $fileName = $this->decodeRFC2231($fileName); } + $fileName = str_replace('/', ' ', $fileName); /** @var scalar|array|object|null */ $sizeInBytes = $partStructure->bytes ?? null;