From: Don Armstrong Date: Sat, 24 Jul 2010 20:54:23 +0000 (-0700) Subject: Don't RFC1522 escape ", ( and ). (Closes: #588859). Thanks to Glenn X-Git-Tag: release/2.6.0~416^2 X-Git-Url: https://git.donarmstrong.com/?p=debbugs.git;a=commitdiff_plain;h=b7cfda67ee4d2c0c337fd8012bfd4690babab44d Don't RFC1522 escape ", ( and ). (Closes: #588859). Thanks to Glenn Morris --- diff --git a/Debbugs/MIME.pm b/Debbugs/MIME.pm index 95dafb8..c2faeaa 100644 --- a/Debbugs/MIME.pm +++ b/Debbugs/MIME.pm @@ -288,8 +288,10 @@ sub encode_rfc1522 { return undef if not defined $rawstr; # We process words in reverse so we can preserve spacing between # encoded words. This regex splits on word|nonword boundaries and - # nonword|nonword boundaries. - my @words = reverse split /(?:(?<=[\s\n])|(?=[\s\n]))/m, $rawstr; + # nonword|nonword boundaries. We also consider parenthesis and " + # to be nonwords to avoid escaping them in comments in violation + # of RFC1522 + my @words = reverse split /(?:(?<=[\s\n\)\(\"])|(?=[\s\n\)\(\"]))/m, $rawstr; my $previous_word_encoded = 0; my $string = ''; diff --git a/debian/changelog b/debian/changelog index c32e565..923c161 100644 --- a/debian/changelog +++ b/debian/changelog @@ -27,6 +27,8 @@ debbugs (2.4.2~exp1) experimental; urgency=low don't use -obq by default anymore. * Add urls to control@ mail footer (Closes: #578822). Thanks to Lars Wirzenius + * Don't RFC1522 escape ", ( and ). (Closes: #588859). Thanks to Glenn + Morris -- Don Armstrong Wed, 26 Aug 2009 21:32:53 -0700 diff --git a/t/01_mime.t b/t/01_mime.t index a759adc..10bf167 100644 --- a/t/01_mime.t +++ b/t/01_mime.t @@ -1,7 +1,7 @@ # -*- mode: cperl;-*- # $Id: 01_mime.t,v 1.1 2005/08/17 21:46:17 don Exp $ -use Test::More tests => 5; +use Test::More tests => 6; use warnings; use strict; @@ -21,6 +21,10 @@ my $test_str2 = <<'END'; Döñ Ärḿßtrøñĝ END +my $test_str3 =<<'END'; +foo@bar.com (J fö"ø) +END + # 1: test decode ok(Debbugs::MIME::decode_rfc1522(q(=?iso-8859-1?Q?D=F6n_Armstr=F3ng?= )) eq encode_utf8(q(Dön Armstróng )),"decode_rfc1522 decodes and converts to UTF8 properly"); @@ -31,6 +35,8 @@ ok(Debbugs::MIME::decode_rfc1522(Debbugs::MIME::encode_rfc1522($test_str)) eq $t "encode_rfc1522 encodes strings that decode_rfc1522 can decode"); ok(Debbugs::MIME::decode_rfc1522(Debbugs::MIME::encode_rfc1522($test_str2)) eq $test_str2, "encode_rfc1522 encodes strings that decode_rfc1522 can decode"); +ok(Debbugs::MIME::decode_rfc1522(Debbugs::MIME::encode_rfc1522($test_str3)) eq $test_str3, + "encode_rfc1522 properly handles parentesis and \""); # Make sure that create_mime_message has encoded headers and doesn't enclude any 8-bit characters