Skip to content

Commit 4066bff

Browse files
committed
Make Content-Disposition header value parsing case-insensitive
Per RFC6266: > If the disposition type matches "attachment" (case-insensitively) (...) > The parameters "filename" and "filename*", to be matched case-insensitively (...)
1 parent a9f7518 commit 4066bff

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/MessagePart.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,16 @@ public function isImage(): bool
126126

127127
public function isAttachment(): bool
128128
{
129-
return str_starts_with($this->getHeader('Content-Disposition', ''), 'attachment');
129+
return str_starts_with(strtolower($this->getHeader('Content-Disposition', '')), 'attachment');
130130
}
131131

132132
public function getFilename(): string
133133
{
134-
if (preg_match('/filename=([^;]+)/', $this->getHeader('Content-Disposition'), $matches)) {
134+
if (preg_match('/filename=([^;]+)/i', $this->getHeader('Content-Disposition'), $matches)) {
135135
return trim($matches[1], '"');
136136
}
137137

138-
if (preg_match('/name=([^;]+)/', $this->getContentType(), $matches)) {
138+
if (preg_match('/name=([^;]+)/i', $this->getContentType(), $matches)) {
139139
return trim($matches[1], '"');
140140
}
141141

0 commit comments

Comments
 (0)