Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 70f703d

Browse filesBrowse files
committed
[Mime] Fix case-sensitive handling in Headers::addHeader()
1 parent 6f8b4cb commit 70f703d
Copy full SHA for 70f703d

File tree

Expand file treeCollapse file tree

2 files changed

+10
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+10
-1
lines changed

‎src/Symfony/Component/Mime/Header/Headers.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Header/Headers.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function addParameterizedHeader(string $name, string $value, array $param
143143
*/
144144
public function addHeader(string $name, $argument, array $more = []): self
145145
{
146-
$parts = explode('\\', self::HEADER_CLASS_MAP[$name] ?? UnstructuredHeader::class);
146+
$parts = explode('\\', self::HEADER_CLASS_MAP[strtolower($name)] ?? UnstructuredHeader::class);
147147
$method = 'add'.ucfirst(array_pop($parts));
148148
if ('addUnstructuredHeader' === $method) {
149149
$method = 'addTextHeader';

‎src/Symfony/Component/Mime/Tests/Header/HeadersTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Tests/Header/HeadersTest.php
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,15 @@ public function testRemoveIsNotCaseSensitive()
239239
$this->assertFalse($headers->has('Message-ID'));
240240
}
241241

242+
public function testAddHeaderIsNotCaseSensitive()
243+
{
244+
$headers = new Headers();
245+
$headers->addHeader('From', ['from@example.com']);
246+
247+
$this->assertInstanceOf(MailboxListHeader::class, $headers->get('from'));
248+
$this->assertEquals([new Address('from@example.com')], $headers->get('from')->getBody());
249+
}
250+
242251
public function testToStringJoinsHeadersTogether()
243252
{
244253
$headers = new Headers();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.