Skip to content

Commit

Permalink
Merge pull request #115 from pali/master
Browse files Browse the repository at this point in the history
Encode::MIME::Header: Fix parsing quoted-printable text in strict mode
  • Loading branch information
dankogai authored Jul 9, 2017
2 parents a2f702b + d889f1b commit f929414
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Encode/MIME/Header.pm
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ my $re_capture_encoded_word_split = qr/=\?($re_charset)((?:\*$re_language)?)\?($
my $re_encoding_strict_b = qr/[Bb]/;
my $re_encoding_strict_q = qr/[Qq]/;
my $re_encoded_text_strict_b = qr/[0-9A-Za-z\+\/]*={0,2}/;
my $re_encoded_text_strict_q = qr/(?:[^\?\s=]|=[0-9A-Fa-f]{2})*/;
my $re_encoded_text_strict_q = qr/(?:[\x21-\x3C\x3E\x40-\x7E]|=[0-9A-Fa-f]{2})*/; # NOTE: first part are printable US-ASCII except ?, =, SPACE and TAB
my $re_encoded_word_strict = qr/=\?$re_charset(?:\*$re_language)?\?(?:$re_encoding_strict_b\?$re_encoded_text_strict_b|$re_encoding_strict_q\?$re_encoded_text_strict_q)\?=/;
my $re_capture_encoded_word_strict = qr/=\?($re_charset)((?:\*$re_language)?)\?($re_encoding_strict_b\?$re_encoded_text_strict_b|$re_encoding_strict_q\?$re_encoded_text_strict_q)\?=/;

Expand Down
6 changes: 5 additions & 1 deletion t/mime-header.t
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use strict;
use utf8;
use charnames ":full";

use Test::More tests => 264;
use Test::More tests => 266;

BEGIN {
use_ok("Encode::MIME::Header");
Expand Down Expand Up @@ -136,6 +136,8 @@ my @decode_default_tests = (
"=?utf8?Q?=C3=A1=f9=80=80=80=80?=" => "á�",
"=?UTF8?Q?=C3=A1=f9=80=80=80=80?=" => "á�",
"=?utf-8-strict?Q?=C3=A1=f9=80=80=80=80?=" => "á�",
# allow non-ASCII characters in q word
"=?UTF-8?Q?\x{C3}\x{A1}?=" => "á",
);

my @decode_strict_tests = (
Expand All @@ -155,6 +157,8 @@ my @decode_strict_tests = (
"=?utf8?Q?=C3=A1?=" => "=?utf8?Q?=C3=A1?=",
"=?UTF8?Q?=C3=A1?=" => "=?UTF8?Q?=C3=A1?=",
"=?utf-8-strict?Q?=C3=A1?=" => "=?utf-8-strict?Q?=C3=A1?=",
# do not allow non-ASCII characters in q word
"=?UTF-8?Q?\x{C3}\x{A1}?=" => "=?UTF-8?Q?\x{C3}\x{A1}?=",
);

my @encode_tests = (
Expand Down

0 comments on commit f929414

Please sign in to comment.