Skip to content

Commit

Permalink
Attachment name parsing fixed #410 #421
Browse files Browse the repository at this point in the history
  • Loading branch information
Webklex committed Jun 28, 2023
1 parent 57e7d28 commit 25fa1a0
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 "";
}
Expand Down

0 comments on commit 25fa1a0

Please sign in to comment.