[BUGFIX] Mail sending fails with quoted&encoded e-mail addresses
authorDmitry Dulepov <dmitry@typo3.org>
Mon, 5 Mar 2012 10:21:18 +0000 (12:21 +0200)
committerJigal van Hemert <jigal@xs4all.nl>
Mon, 12 Mar 2012 21:00:43 +0000 (22:00 +0100)
Mail sending fails if the name in the e-mail address is quoted
but requires encoding to base64 or quoted-printable. The
t3lib_div::encodeHeader() function encodes the name without
taking quotation into account.

Change-Id: Id421914c221cfa26e5198c936abdc9156406995b
Resolves: #34526
Releases: 4.5, 4.6, 4.7
Reviewed-on: http://review.typo3.org/9596
Reviewed-by: Jigal van Hemert
Tested-by: Jigal van Hemert
t3lib/class.t3lib_div.php

index 5d38feb..fa7a2c0 100644 (file)
@@ -5736,6 +5736,8 @@ final class t3lib_div {
                $matches = preg_split('/(.?###.+###.?|\(|\))/', $line, -1, PREG_SPLIT_NO_EMPTY);
                foreach ($matches as $part) {
                        $oldPart = $part;
+                       $partWasQuoted = ($part{0} == '"');
+                       $part = trim($part, '"');
                        switch ((string) $enc) {
                                case 'base64':
                                        $part = '=?' . $charset . '?B?' . base64_encode($part) . '?=';
@@ -5754,6 +5756,9 @@ final class t3lib_div {
                                        }
                                        break;
                        }
+                       if ($partWasQuoted) {
+                               $part = '"' . $part . '"';
+                       }
                        $line = str_replace($oldPart, $part, $line);
                }
                $line = preg_replace('/###(.+?)###/', '$1', $line); // Remove the wrappers