Overview
Comment: | Try to fix issues with mail headers decoding |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | 7.3 |
Files: | files | file ages | folders |
SHA1: |
7584868379a3e1cd546f87f715a4fd4d |
User & Date: | bohwaz on 2021-07-29 07:28:23 |
Other Links: | branch diff | manifest | tags |
Context
2021-09-14
| ||
20:28 | Fix SkrivLite call of extensions when there are no arguments check-in: d63c22fa14 user: bohwaz tags: 7.3 | |
2021-07-29
| ||
07:28 | Try to fix issues with mail headers decoding check-in: 7584868379 user: bohwaz tags: 7.3 | |
2021-07-24
| ||
13:45 | Fix iconv decoding error when an UTF-8 entity was split between multiple lines check-in: ce17ec3e8d user: bohwaz tags: 7.3 | |
Changes
Modified src/lib/KD2/Mail_Message.php from [572492cdd4] to [a1e1c7133a].
︙ | ︙ | |||
843 844 845 846 847 848 849 | $value = rtrim($value); if (strpos($value, '=?') === false) { return $this->utf8_encode($value); } | > > > > > > > > | < < < | < | < | < < < < | | 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 | $value = rtrim($value); if (strpos($value, '=?') === false) { return $this->utf8_encode($value); } if (function_exists('iconv_mime_decode')) { $value = $this->utf8_encode(iconv_mime_decode($value, ICONV_MIME_DECODE_CONTINUE_ON_ERROR)); } elseif (function_exists('mb_decode_mimeheader')) { $value = $this->utf8_encode(mb_decode_mimeheader($value)); } elseif (function_exists('imap_mime_header_decode')) { $_value = ''; // subject can span into several lines foreach (imap_mime_header_decode($value) as $h) { $charset = ($h->charset == 'default') ? 'US-ASCII' : $h->charset; $_value .= iconv($charset, "UTF-8//TRANSLIT", $h->text); } $value = $_value; } return $value; } protected function _decodeMultipart($lines) { |
︙ | ︙ |
Modified src/tests/mail_message.php from [c353b7054f] to [c5cc2c6b78].
︙ | ︙ | |||
17 18 19 20 21 22 23 24 25 26 27 28 29 30 | $msg = new Mail_Message; $msg->setHeader('X-Test', str_repeat('aAbB', 1000)); $msg->setBody(str_repeat('cCdD', 1000)); Test::assert(!preg_match("/[^\r\n]{999,}/", $msg->outputHeaders())); Test::assert(!preg_match("/[^\r\n]{999,}/", $msg->outputBody())); } /** * Check that we do keep line breaks in headers when outputting * but not when using getHeader() */ function test_headers_multiline() { | > > > > > > > > > > > > > > > > > > > > | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | $msg = new Mail_Message; $msg->setHeader('X-Test', str_repeat('aAbB', 1000)); $msg->setBody(str_repeat('cCdD', 1000)); Test::assert(!preg_match("/[^\r\n]{999,}/", $msg->outputHeaders())); Test::assert(!preg_match("/[^\r\n]{999,}/", $msg->outputBody())); } function test_headers_iconv() { $headers = <<<EOF Date: Wed, 28 Jul 2021 20:42:01 +0200 From: =?UTF-8?B?U3TDqXBoYW5l?= G <stephane@example.invalid> Subject: Fw: Interventions centres de loisirs - manque de =?UTF-8?B?U3TDqXBoYW5l?= =?UTF-8?B?U3TDqXBoYW5l?= enfants Organization: La rustine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Message-Id: <E1m8oVH-000368-W0@mail.kd2.org> EOF; $msg = new Mail_Message; $msg->parse(trim($headers)); Test::assertEquals($msg->getFrom(), 'Stéphane G <stephane@example.invalid>'); } /** * Check that we do keep line breaks in headers when outputting * but not when using getHeader() */ function test_headers_multiline() { |
︙ | ︙ |