[Rt-commit] rt branch, 4.0/mimeword-decoding-quotes, created. rt-4.0.12-7-gd207109

Thomas Sibley trs at bestpractical.com
Wed May 1 22:45:47 EDT 2013


The branch, 4.0/mimeword-decoding-quotes has been created
        at  d20710945e32e8901a597b1909f365314c419483 (commit)

- Log -----------------------------------------------------------------
commit 71e589b033c17419a18727104257e2a20626bb89
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Wed May 1 19:43:09 2013 -0700

    Failing test demonstrating incorrect MIME word decoding with quotes
    
    Extra quotes appear around MIME words containing special chars, such as
    a comma.  See [rt3 #23813].

diff --git a/t/mail/mime_decoding.t b/t/mail/mime_decoding.t
index 4b3e3c0..fbf8849 100644
--- a/t/mail/mime_decoding.t
+++ b/t/mail/mime_decoding.t
@@ -1,6 +1,6 @@
 use strict;
 use warnings;
-use RT::Test nodb => 1, tests => 13;
+use RT::Test nodb => 1, tests => 14;
 
 use_ok('RT::I18N');
 
@@ -34,6 +34,16 @@ diag q{'=' char in a trailing part after an encoded part};
     );
 }
 
+diag q{adding quotes around mime words containing specials when word is already quoted};
+{
+    my $str = <<"END";
+Content-Disposition: attachment; filename="=?iso-8859-1?Q?foobar,_?=
+ =?iso-8859-1?Q?barfoo.docx?="
+END
+    my $decoded = 'Content-Disposition: attachment; filename="foobar, barfoo.docx"';
+    is( RT::I18N::DecodeMIMEWordsToUTF8($str), $decoded, "No added quotes" );
+}
+
 diag q{regression test for #5248 from rt3.fsck.com};
 {
     my $str = qq{Subject: =?ISO-8859-1?Q?Re=3A_=5BXXXXXX=23269=5D_=5BComment=5D_Frag?=}

commit d20710945e32e8901a597b1909f365314c419483
Author: Jukka Laaksola <jukka.laaksola at netland.fi>
Date:   Wed May 1 19:34:18 2013 -0700

    Avoid adding too many quotes around decoded MIME words
    
    As demonstrated by the tests in the previous commit.
    
    This case, and much more, is handled better by
    4.2-on-4.0/protect-more-chars-while-decoding-headers, but that branch is
    destined for 4.2.  For now, simply check the leading and trailing
    snippets around the matched word for quotes.
    
    See [rt3 #23813].

diff --git a/lib/RT/I18N.pm b/lib/RT/I18N.pm
index 0e75b9f..0b8ced0 100644
--- a/lib/RT/I18N.pm
+++ b/lib/RT/I18N.pm
@@ -388,6 +388,7 @@ sub DecodeMIMEWordsToEncoding {
             $enc_str = qq{"$enc_str"}
                 if $enc_str =~ /[,;]/
                 and $enc_str !~ /^".*"$/
+                and $prefix !~ /"$/ and $trailing !~ /^"/
                 and (!$field || $field =~ /^(?:To$|From$|B?Cc$|Content-)/i);
 
             $str .= $prefix . $enc_str . $trailing;

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


More information about the Rt-commit mailing list