Skip to content

Commit

Permalink
bug #44732 [Mime] Relaxing in-reply-to header validation (ThomasLanda…
Browse files Browse the repository at this point in the history
…uer)

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
  • Loading branch information
fabpot committed Dec 21, 2021
2 parents 0558be7 + 04ddc12 commit 3526a32
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Symfony/Component/Mime/Header/Headers.php
Expand Up @@ -141,8 +141,8 @@ public function add(HeaderInterface $header): self
'cc' => MailboxListHeader::class,
'bcc' => MailboxListHeader::class,
'message-id' => IdentificationHeader::class,
'in-reply-to' => IdentificationHeader::class,
'references' => IdentificationHeader::class,
'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 ...
'references' => UnstructuredHeader::class, // ... `Message-ID`, even if that is no valid `msg-id`
'return-path' => PathHeader::class,
];

Expand Down
14 changes: 14 additions & 0 deletions src/Symfony/Component/Mime/Tests/Header/HeadersTest.php
Expand Up @@ -243,4 +243,18 @@ public function testToArray()
"Foo: =?utf-8?Q?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa?=\r\n =?utf-8?Q?aaaa?=",
], $headers->toArray());
}

public function testInReplyToAcceptsNonIdentifierValues()
{
$headers = new Headers();
$headers->addHeader('In-Reply-To', 'foobar');
$this->assertEquals('foobar', $headers->get('In-Reply-To')->getBody());
}

public function testReferencesAcceptsNonIdentifierValues()
{
$headers = new Headers();
$headers->addHeader('References' , 'foobar');
$this->assertEquals('foobar', $headers->get('References')->getBody());
}
}

0 comments on commit 3526a32

Please sign in to comment.