Skip to content

Commit

Permalink
Content-Transfer-Encoding value not case sensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
denis-sokolov authored and ThaDafinser committed Mar 25, 2014
1 parent 606f6fe commit abbbeea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/Zend/Mail/Header/ContentTransferEncoding.php
Expand Up @@ -91,6 +91,9 @@ public function toString()
*/
public function setTransferEncoding($transferEncoding)
{
// Per RFC 1521, the value of the header is not case sensitive
$transferEncoding = strtolower($transferEncoding);

if (!in_array($transferEncoding, self::$allowedTransferEncodings)) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects one of "'. implode(', ', self::$allowedTransferEncodings) . '"; received "%s"',
Expand Down
7 changes: 7 additions & 0 deletions tests/ZendTest/Mail/Header/ContentTransferEncodingTest.php
Expand Up @@ -43,6 +43,13 @@ public function testContentTransferEncodingGetFieldValueReturnsProperValue()
$this->assertEquals('7bit', $contentTransferEncodingHeader->getFieldValue());
}

public function testContentTransferEncodingHandlesCaseInsensitivity()
{
$encoding = new ContentTransferEncoding();
$encoding->setTransferEncoding('quOtED-printAble');
$this->assertEquals('quoted-printable', strtolower($encoding->getFieldValue()));
}

public function testContentTransferEncodingToStringReturnsHeaderFormattedString()
{
$contentTransferEncodingHeader = new ContentTransferEncoding();
Expand Down

0 comments on commit abbbeea

Please sign in to comment.