From dfd4cbeda0cad0aa54635580bee2de4ab0e18cd0 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Wed, 27 Mar 2019 19:30:46 +0300 Subject: [PATCH] add ability to support alternative charset names --- src/Fetch/Message.php | 8 ++++++++ tests/Fetch/Test/MIMETest.php | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/src/Fetch/Message.php b/src/Fetch/Message.php index 27c3dc8..3419862 100644 --- a/src/Fetch/Message.php +++ b/src/Fetch/Message.php @@ -191,6 +191,10 @@ class Message */ public static $charsetFlag = '//TRANSLIT'; + public static $charsetRenames = array( + 'ks_c_5601-1987' => 'CP949', + ); + /** * These constants can be used to easily access available flags */ @@ -576,6 +580,10 @@ class Message $from = strtolower($from); $to = strtolower($to); + if (isset(self::$charsetRenames[$from])) { + $from = self::$charsetRenames[$from]; + } + if ($from === $to) { if ($to === 'utf-8') { return UTF8::fix($text); diff --git a/tests/Fetch/Test/MIMETest.php b/tests/Fetch/Test/MIMETest.php index 1685f5c..cfef200 100644 --- a/tests/Fetch/Test/MIMETest.php +++ b/tests/Fetch/Test/MIMETest.php @@ -42,6 +42,12 @@ class MIMETest extends \PHPUnit_Framework_TestCase '?????? ?????.pdf', '=?UTF-8?B?' .base64_encode("\xCF\xF0\xE8\xEC\xE5\xF0 \xEF\xEB\xE0\xED\xE0\x2E\x70\x64\x66") . '?=', ), + array( + ' (ИСТРЕБИТЕЛЬ ЛЕТАЮЩИХ НАСЕКОМЫХ "БАРГУЗИН" КП ДИЛЕР - 2019г)', + ' =?ks_c_5601-1987?B?ICisqqyzrLSssqymrKKsqqy0rKasray+IKytrKastKyhrMCsu6yq?=' . + ' =?ks_c_5601-1987?B?rLcgrK+soayzrKasrKywrK6svay3ICKsoqyhrLKspKy1?=' . + ' =?ks_c_5601-1987?B?rKmsqqyvIiCsrKyxIKylrKqsraymrLIgLSAyMDE5rNQp?=', + ), ); }