[Rt-commit] rt branch, 4.2/encoded-word-spaces, created. rt-4.2.13-53-gbdd6bd9

Alex Vandiver alexmv at bestpractical.com
Thu Sep 1 04:36:39 EDT 2016


The branch, 4.2/encoded-word-spaces has been created
        at  bdd6bd96ece4faebb5a067bdd787b8e2e4fec755 (commit)

- Log -----------------------------------------------------------------
commit bdd6bd96ece4faebb5a067bdd787b8e2e4fec755
Author: Alex Vandiver <alex at chmrr.net>
Date:   Thu Sep 1 01:32:34 2016 -0700

    Stop removing space before 2nd and later MIME encoded-words
    
    RFC 2047 is clear that only whitespace between encoded-word tokens is
    to be stripped; space before them is significant.  However, RT trimmed
    whitespace before all but the first encoded-word.  e541307d6e
    introduced this trimming, along with a number of other suspect
    internationalization fixes.
    
    Remove this space trimming, document the absolutely correct `tr/_/ /`
    replacement, and add a test for this behavior.

diff --git a/lib/RT/I18N.pm b/lib/RT/I18N.pm
index 60a6622..a37f07d 100644
--- a/lib/RT/I18N.pm
+++ b/lib/RT/I18N.pm
@@ -442,11 +442,9 @@ sub _DecodeMIMEWordsToEncoding {
         $charset  = _CanonicalizeCharset($charset);
         $encoding = lc $encoding;
 
-        $trailing =~ s/\s?\t?$//;               # Observed from Outlook Express
-
         if ( $encoding eq 'q' ) {
             use MIME::QuotedPrint;
-            $enc_str =~ tr/_/ /;                # Observed from Outlook Express
+            $enc_str =~ tr/_/ /;              # RFC 2047, 4.2 (2)
             $enc_str = decode_qp($enc_str);
         } elsif ( $encoding eq 'b' ) {
             use MIME::Base64;
diff --git a/t/mail/mime_decoding.t b/t/mail/mime_decoding.t
index 1126f1f..9759071 100644
--- a/t/mail/mime_decoding.t
+++ b/t/mail/mime_decoding.t
@@ -236,4 +236,14 @@ diag "quotes in filename";
     );
 }
 
+diag "Alternating encoded-words and not, space is preserved";
+{
+    my $str = q{A =?UTF-8?Q?B?= C =?UTF-8?Q?D?= E =?UTF-8?Q?F?= G};
+    is_string(
+        RT::I18N::DecodeMIMEWordsToUTF8($str, "Subject"),
+        q{A B C D E F G},
+        "Space is preserved between encoded-words and not"
+    );
+}
+
 done_testing;

-----------------------------------------------------------------------


More information about the rt-commit mailing list