-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make legacy "wrong" RFC2047 encoding apply only to one header
- Loading branch information
1 parent
ed8d050
commit 32f7157
Showing
2 changed files
with
26 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -205,16 +205,25 @@ public function testValueAndParamCanBeEncodedIfNonAscii() | |
$header = new ParameterizedHeader('X-Foo', $value); | ||
$header->setCharset('iso-8859-1'); | ||
$header->setParameters(['says' => $value]); | ||
$this->assertEquals('X-Foo: =?'.$header->getCharset().'?Q?fo=8Fbar?=; says="=?'.$header->getCharset().'?Q?fo=8Fbar?="', $header->toString()); | ||
$this->assertEquals('X-Foo: =?'.$header->getCharset().'?Q?fo=8Fbar?=; says*='.$header->getCharset()."''fo%8Fbar", $header->toString()); | ||
} | ||
|
||
public function testParamsAreEncodedWithEncodedWordsIfNoParamEncoderSet() | ||
public function testParamsAreEncodedIfNonAscii() | ||
{ | ||
$value = 'fo'.pack('C', 0x8F).'bar'; | ||
$header = new ParameterizedHeader('X-Foo', 'bar'); | ||
$header->setCharset('iso-8859-1'); | ||
$header->setParameters(['says' => $value]); | ||
$this->assertEquals('X-Foo: bar; says="=?'.$header->getCharset().'?Q?fo=8Fbar?="', $header->toString()); | ||
$this->assertEquals('X-Foo: bar; says*='.$header->getCharset()."''fo%8Fbar", $header->toString()); | ||
} | ||
|
||
public function testParamsAreEncodedWithLegacyEncodingEnabled() | ||
{ | ||
$value = 'fo'.pack('C', 0x8F).'bar'; | ||
$header = new ParameterizedHeader('Content-Type', 'bar'); | ||
$header->setCharset('iso-8859-1'); | ||
$header->setParameters(['says' => $value]); | ||
$this->assertEquals('Content-Type: bar; says="=?'.$header->getCharset().'?Q?fo=8Fbar?="', $header->toString()); | ||
} | ||
|
||
public function testLanguageInformationAppearsInEncodedWords() | ||
|
@@ -234,14 +243,26 @@ public function testLanguageInformationAppearsInEncodedWords() | |
tag. For example: | ||
From: =?US-ASCII*EN?Q?Keith_Moore?= <[email protected]> | ||
-- RFC 2047, 5. Use of encoded-words in message headers | ||
... | ||
+ An 'encoded-word' MUST NOT be used in parameter of a MIME | ||
Content-Type or Content-Disposition field, or in any structured | ||
field body except within a 'comment' or 'phrase'. | ||
-- RFC 2047, Appendix - changes since RFC 1522 | ||
... | ||
+ clarify that encoded-words are allowed in '*text' fields in both | ||
RFC822 headers and MIME body part headers, but NOT as parameter | ||
values. | ||
*/ | ||
|
||
$value = 'fo'.pack('C', 0x8F).'bar'; | ||
$header = new ParameterizedHeader('X-Foo', $value); | ||
$header->setCharset('iso-8859-1'); | ||
$header->setLanguage('en'); | ||
$header->setParameters(['says' => $value]); | ||
$this->assertEquals('X-Foo: =?'.$header->getCharset().'*en?Q?fo=8Fbar?=; says="=?'.$header->getCharset().'*en?Q?fo=8Fbar?="', $header->toString()); | ||
$this->assertEquals('X-Foo: =?'.$header->getCharset().'*en?Q?fo=8Fbar?=; says*='.$header->getCharset()."'en'fo%8Fbar", $header->toString()); | ||
} | ||
|
||
public function testSetBody() | ||
|