Skip Menu |
 

This queue is for tickets about the Encode CPAN distribution.

Report information
The Basics
Id: 104422
Status: resolved
Priority: 0/
Queue: Encode

People
Owner: Nobody in particular
Requestors: cpan [...] rjlov.fastmail.fm
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: decode('MIME-header') does not properly join similar Q encoded-words
Date: Thu, 14 May 2015 17:23:06 +1000
To: bug-Encode [...] rt.cpan.org
From: Richard Lovejoy <cpan [...] rjlov.fastmail.fm>
Download (untitled) / with headers
text/plain 884b
The regexp designed to join encoded words together needs some adjustment. The .*? can overrun an encoded-word, meaning that encoded-words with incompatible charsets or encodings may be combined. For example: decode("MIME-Header","=?utf-8?Q?pre?= =?utf-8?B?IGZvbw==?= =?utf-8?Q?bar?=") expected: "pre foobar" actual: "pre foo" This patch fixes the problem, I believe: --- old/Encode/MIME/Header.pm 2015-05-14 17:14:41.000000000 +1000 +++ new/Encode/MIME/Header.pm 2015-05-14 17:16:05.800000000 +1000 @@ -47,7 +47,7 @@ $str =~ s/(?:\r\n|[\r\n])[ \t]//gos; 1 while ( $str =~ - s/(=\?[-0-9A-Za-z_]+\?[Qq]\?)(.*?)\?=\1(.*?\?=)/$1$2$3/ ) + s/(=\?[-0-9A-Za-z_]+\?[Qq]\?)([^?]*?)\?=\1([^?]*?\?=)/$1$2$3/ ) ; # Concat consecutive QP encoded mime headers # Fixes breaking inside multi-byte characters Richard. -- Richard Lovejoy
Download (untitled) / with headers
text/plain 1.1k
Thank you. Your patch is in as: https://github.com/dankogai/p5-encode/commit/2df66d62d718bd35b0fe8a1cff33b91117c88d06 Dan the Maintainer Thereof On Thu May 14 03:23:19 2015, cpan@rjlov.fastmail.fm wrote: Show quoted text
> > The regexp designed to join encoded words together needs some > adjustment. The .*? can overrun an encoded-word, meaning that > encoded-words with incompatible charsets or encodings may be combined. > > For example: > decode("MIME-Header","=?utf-8?Q?pre?= =?utf-8?B?IGZvbw==?= > =?utf-8?Q?bar?=") > expected: "pre foobar" > actual: "pre foo" > > > > This patch fixes the problem, I believe: > > --- old/Encode/MIME/Header.pm 2015-05-14 17:14:41.000000000 +1000 > +++ new/Encode/MIME/Header.pm 2015-05-14 17:16:05.800000000 +1000 > @@ -47,7 +47,7 @@ > $str =~ s/(?:\r\n|[\r\n])[ \t]//gos; > > 1 while ( $str =~ > - s/(=\?[-0-9A-Za-z_]+\?[Qq]\?)(.*?)\?=\1(.*?\?=)/$1$2$3/ ) > + s/(=\?[-0-9A-Za-z_]+\?[Qq]\?)([^?]*?)\?=\1([^?]*?\?=)/$1$2$3/ ) > ; # Concat consecutive QP encoded mime headers > # Fixes breaking inside multi-byte characters > > > > Richard. > -- > Richard Lovejoy >


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.