Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3526a32

Browse files
committed
bug #44732 [Mime] Relaxing in-reply-to header validation (ThomasLandauer)
This PR was submitted for the 6.1 branch but it was squashed and merged into the 4.4 branch instead. Discussion ---------- [Mime] Relaxing in-reply-to header validation | Q | A | ------------- | --- | Branch? | 6.1 | Bug fix? | no | New feature? | ? | Deprecations? | no | Tickets | Fix #37361 | License | MIT | Doc PR | not necessary @nicolas-grekas 1. Is it OK to just use `UnstructuredHeader`? 2. Some tests at `IdentificationHeaderTest` are irrelevant now (but still pass) - should I remove them? And create some new test cases in `UnstructuredHeaderTest`? Or rely on every aspect being tested with other headers there, and don't add anything? Commits ------- 04ddc12 [Mime] Relaxing in-reply-to header validation
2 parents 0558be7 + 04ddc12 commit 3526a32

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ public function add(HeaderInterface $header): self
141141
'cc' => MailboxListHeader::class,
142142
'bcc' => MailboxListHeader::class,
143143
'message-id' => IdentificationHeader::class,
144-
'in-reply-to' => IdentificationHeader::class,
145-
'references' => IdentificationHeader::class,
144+
'in-reply-to' => UnstructuredHeader::class, // `In-Reply-To` and `References` are less strict than RFC 2822 (3.6.4) to allow users entering the original email's ...
145+
'references' => UnstructuredHeader::class, // ... `Message-ID`, even if that is no valid `msg-id`
146146
'return-path' => PathHeader::class,
147147
];
148148

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,4 +243,18 @@ public function testToArray()
243243
"Foo: =?utf-8?Q?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa?=\r\n =?utf-8?Q?aaaa?=",
244244
], $headers->toArray());
245245
}
246+
247+
public function testInReplyToAcceptsNonIdentifierValues()
248+
{
249+
$headers = new Headers();
250+
$headers->addHeader('In-Reply-To', 'foobar');
251+
$this->assertEquals('foobar', $headers->get('In-Reply-To')->getBody());
252+
}
253+
254+
public function testReferencesAcceptsNonIdentifierValues()
255+
{
256+
$headers = new Headers();
257+
$headers->addHeader('References' , 'foobar');
258+
$this->assertEquals('foobar', $headers->get('References')->getBody());
259+
}
246260
}

0 commit comments

Comments
 (0)