diff --git a/src/Header/AbstractAddressList.php b/src/Header/AbstractAddressList.php index 76723ce3..33bac068 100644 --- a/src/Header/AbstractAddressList.php +++ b/src/Header/AbstractAddressList.php @@ -66,7 +66,7 @@ abstract class AbstractAddressList implements HeaderInterface */ public static function fromString($headerLine) { - $headerLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR); + $headerLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); // split into name/value list($fieldName, $fieldValue) = explode(': ', $headerLine, 2); @@ -98,7 +98,7 @@ public static function fromString($headerLine) if (empty($name)) { $name = null; } else { - $name = iconv_mime_decode($name, ICONV_MIME_DECODE_CONTINUE_ON_ERROR); + $name = iconv_mime_decode($name, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); } if (isset($matches['namedEmail'])) { diff --git a/src/Header/ContentType.php b/src/Header/ContentType.php index 83e0f9d2..b41bb3d5 100755 --- a/src/Header/ContentType.php +++ b/src/Header/ContentType.php @@ -58,7 +58,7 @@ class ContentType implements HeaderInterface */ public static function fromString($headerLine) { - $headerLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR); + $headerLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); list($name, $value) = explode(': ', $headerLine, 2); // check to ensure proper header type for this factory diff --git a/src/Header/GenericHeader.php b/src/Header/GenericHeader.php index abeda9ca..ceb748ba 100644 --- a/src/Header/GenericHeader.php +++ b/src/Header/GenericHeader.php @@ -55,7 +55,7 @@ class GenericHeader implements HeaderInterface */ public static function fromString($headerLine) { - $headerLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR); + $headerLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); $parts = explode(': ', $headerLine, 2); if (count($parts) != 2) { throw new Exception\InvalidArgumentException('Header must match with the format "name: value"'); diff --git a/src/Header/GenericMultiHeader.php b/src/Header/GenericMultiHeader.php index a7938783..60125d56 100644 --- a/src/Header/GenericMultiHeader.php +++ b/src/Header/GenericMultiHeader.php @@ -40,7 +40,7 @@ class GenericMultiHeader extends GenericHeader implements MultipleHeadersInterfa */ public static function fromString($headerLine) { - $headerLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR); + $headerLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); $parts = explode(': ', $headerLine, 2); if (count($parts) != 2) { throw new Exception\InvalidArgumentException('Header must match with the format "name: value"'); diff --git a/src/Header/Sender.php b/src/Header/Sender.php index 1bbdad82..8f707eba 100644 --- a/src/Header/Sender.php +++ b/src/Header/Sender.php @@ -53,7 +53,7 @@ class Sender implements HeaderInterface */ public static function fromString($headerLine) { - $headerLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR); + $headerLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); list($name, $value) = explode(': ', $headerLine, 2); // check to ensure proper header type for this factory @@ -69,7 +69,7 @@ public static function fromString($headerLine) if (empty($name)) { $name = null; } else { - $name = iconv_mime_decode($name, ICONV_MIME_DECODE_CONTINUE_ON_ERROR); + $name = iconv_mime_decode($name, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); } $header->setAddress($matches['email'], $name); } diff --git a/src/Header/Subject.php b/src/Header/Subject.php index 6adeef83..8b930d68 100644 --- a/src/Header/Subject.php +++ b/src/Header/Subject.php @@ -51,7 +51,7 @@ class Subject implements UnstructuredInterface */ public static function fromString($headerLine) { - $headerLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR); + $headerLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); list($name, $value) = explode(': ', $headerLine, 2); // check to ensure proper header type for this factory diff --git a/test/Header/HeaderWrapTest.php b/test/Header/HeaderWrapTest.php index 8abf02ed..95959004 100644 --- a/test/Header/HeaderWrapTest.php +++ b/test/Header/HeaderWrapTest.php @@ -61,7 +61,7 @@ public function testWrapUnstructuredHeaderMime() $test = HeaderWrap::wrap($string, $header); $this->assertEquals($expected, $test); - $this->assertEquals($string, iconv_mime_decode($test)); + $this->assertEquals($string, iconv_mime_decode($test, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8')); } /** diff --git a/test/Storage/MessageTest.php b/test/Storage/MessageTest.php index 76bdbe28..3dde469f 100644 --- a/test/Storage/MessageTest.php +++ b/test/Storage/MessageTest.php @@ -74,8 +74,7 @@ public function testGetDecodedHeader() { $message = new Message(array('file' => $this->_file)); - $this->assertEquals($message->from, iconv('UTF-8', iconv_get_encoding('internal_encoding'), - '"Peter Müller" ')); + $this->assertEquals('"Peter Müller" ', $message->from); } public function testGetHeaderAsArray() @@ -213,9 +212,7 @@ public function testIterator() public function testDecodeString() { $is = Mime\Decode::decodeQuotedPrintable('=?UTF-8?Q?"Peter M=C3=BCller"?= '); - $should = iconv('UTF-8', iconv_get_encoding('internal_encoding'), - '"Peter Müller" '); - $this->assertEquals($is, $should); + $this->assertEquals('"Peter Müller" ', $is); } public function testSplitHeader()