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 = '';
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 <don@debian.org> Wed, 26 Aug 2009 21:32:53 -0700
# -*- 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;
Döñ Ärḿßtrøñĝ <don@donarmstrong.com>
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?= <don@donarmstrong.com>)) eq
encode_utf8(q(Dön Armstróng <don@donarmstrong.com>)),"decode_rfc1522 decodes and converts to UTF8 properly");
"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