Permalink
Browse files

Merge pull request #2284 from weierophinney/hotfix/zf2-507

[ZF2-507] Ensure Date header is ASCII encoded
  • Loading branch information...
2 parents 1098ddf + 8d4f748 commit 9e940b9de699c42e8611c2cf0626a4c6738ee5ad @EvanDotPro EvanDotPro committed Aug 31, 2012
Showing with 17 additions and 1 deletion.
  1. +2 −1 library/Zend/Mail/Message.php
  2. +15 −0 tests/ZendTest/Mail/MessageTest.php
@@ -103,7 +103,8 @@ public function getHeaders()
{
if (null === $this->headers) {
$this->setHeaders(new Headers());
- $this->headers->addHeaderLine('Date', date('r'));
+ $date = Header\Date::fromString('Date: ' . date('r'));
+ $this->headers->addHeader($date);
}
return $this->headers;
}
@@ -632,4 +632,19 @@ public function testSettingNonAsciiEncodingForcesMimeEncodingOfSomeHeaders()
$expected = 'Subject: =?UTF-8?Q?This=20is=20a=20subject?=';
$this->assertContains($expected, $test);
}
+
+ /**
+ * @group ZF2-507
+ */
+ public function testDefaultDateHeaderEncodingIsAlwaysAscii()
+ {
+ $this->message->setEncoding('utf-8');
+ $headers = $this->message->getHeaders();
+ $header = $headers->get('date');
+ $date = date('r');
+ $date = substr($date, 0, 16);
+ $test = $header->getFieldValue();
+ $test = substr($test, 0, 16);
+ $this->assertEquals($date, $test);
+ }
}

0 comments on commit 9e940b9

Please sign in to comment.