Skip Menu |

This queue is for tickets about the MIME-tools CPAN distribution.

Report information
The Basics
Id: 66779
Status: resolved
Priority: 0/
Queue: MIME-tools

People
Owner: dfs+pause [...] roaringpenguin.com
Requestors: sunnavy [...] gmail.com
Cc: cpan [...] jibsheet.com
AdminCc:

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



Hi I'm confused of the behavior of MIME::WordDecoder::UTF_8, what I guess is MIME::WordDecoder will decode encoded string to perl internal format (e.g. utf8), but both 5.501 and 5.502 return strings with '\xC3\xB1' or alike, which is very weird, maybe it's a bug? I attached a test file for this too. best wishes sunnavy
Subject: mimeworddecoder.t
use strict; use warnings; use Test::More; use MIME::WordDecoder; use Encode; use utf8; my $wd = supported MIME::WordDecoder 'UTF-8'; is( $wd->decode(encode_utf8('ñ')), 'ñ', 'MIME::WordDecoder::UTF_8::decode' ); done_testing();
Subject: Re: [rt.cpan.org #66779]
Date: Tue, 22 Mar 2011 12:54:50 -0400
To: bug-MIME-tools [...] rt.cpan.org
From: "David F. Skoll" <dfs [...] roaringpenguin.com>
On Tue, 22 Mar 2011 11:45:14 -0400 "sunnavy via RT" <bug-MIME-tools@rt.cpan.org> wrote: Show quoted text
> I'm confused of the behavior of MIME::WordDecoder::UTF_8,
You should not be using that directly. See the docs in 5.502: WARNING: Most of this module is deprecated and may disappear. The only function you should use for MIME decoding is "mime_to_perl_string". That function should be passed a MIME-encoded string, not a UTF-8 string. Regards, David.
Subject: Re: [rt.cpan.org #66779]
Date: Wed, 23 Mar 2011 11:27:44 +0800
To: "David F. Skoll via RT" <bug-MIME-tools [...] rt.cpan.org>
From: sunnavy <sunnavy [...] gmail.com>
ah, it's just a test, the relative code is in MIME::Head::recommended_filename. we got a problem that MIME::Head::recommended_filename returns strings like "\x.." sunnavy On 11-03-22 12:55, David F. Skoll via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=66779 > > > On Tue, 22 Mar 2011 11:45:14 -0400 > "sunnavy via RT" <bug-MIME-tools@rt.cpan.org> wrote: >
> > I'm confused of the behavior of MIME::WordDecoder::UTF_8,
> > You should not be using that directly. See the docs in 5.502: > > WARNING: Most of this module is deprecated and may disappear. The only > function you should use for MIME decoding is "mime_to_perl_string". > > That function should be passed a MIME-encoded string, not a UTF-8 string. > > Regards, > > David. >
Subject: Re: [rt.cpan.org #66779]
Date: Wed, 23 Mar 2011 11:25:28 -0400
To: bug-MIME-tools [...] rt.cpan.org
From: "David F. Skoll" <dfs [...] roaringpenguin.com>
On Tue, 22 Mar 2011 23:28:03 -0400 "sunnavy via RT" <bug-MIME-tools@rt.cpan.org> wrote: Show quoted text
> we got a problem that MIME::Head::recommended_filename returns > strings like "\x.."
Ah, I see. Could you send me a sample MIME message that causes that? Regards, David.
Subject: Re: [rt.cpan.org #66779]
Date: Thu, 24 Mar 2011 12:03:43 +0800
To: "David F. Skoll via RT" <bug-MIME-tools [...] rt.cpan.org>
From: sunnavy <sunnavy [...] gmail.com>
I attached another test file for this, see attached. it passes with 5.500 but not with 5.501 and 5.502 thanks sunnavy On 11-03-23 11:25, David F. Skoll via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=66779 > > > On Tue, 22 Mar 2011 23:28:03 -0400 > "sunnavy via RT" <bug-MIME-tools@rt.cpan.org> wrote: >
> > we got a problem that MIME::Head::recommended_filename returns > > strings like "\x.."
> > Ah, I see. Could you send me a sample MIME message that causes that? > > Regards, > > David. >

Message body is not shown because sender requested not to inline it.

Subject: Re: [rt.cpan.org #66779]
Date: Thu, 24 Mar 2011 07:06:28 -0400
To: bug-MIME-tools [...] rt.cpan.org
From: "David F. Skoll" <dfs [...] roaringpenguin.com>
Hi, That's not a valid MIME file. You're not allowed to have raw UTF-8 in the headers; they need to be encoded. Regards, David.
Subject: Re: [rt.cpan.org #66779]
Date: Fri, 25 Mar 2011 00:49:03 +0800
To: "David F. Skoll via RT" <bug-MIME-tools [...] rt.cpan.org>
From: sunnavy <sunnavy [...] gmail.com>
hmm, the test file is utf8 encoded. my $ent = MIME::Entity->build( Type => "text/plain", Filename => "ñ.txt", Data => [], ); If this way is not allowed, how can I build a valid MIME with MIME::Entity? On 11-03-24 07:06, David F. Skoll via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=66779 > > > Hi, > > That's not a valid MIME file. You're not allowed to have raw UTF-8 > in the headers; they need to be encoded. > > Regards, > > David. >
Subject: Re: [rt.cpan.org #66779]
Date: Thu, 24 Mar 2011 13:30:37 -0400
To: bug-MIME-tools [...] rt.cpan.org
From: "David F. Skoll" <dfs [...] roaringpenguin.com>
On Thu, 24 Mar 2011 12:49:23 -0400 "sunnavy via RT" <bug-MIME-tools@rt.cpan.org> wrote: Show quoted text
> hmm, the test file is utf8 encoded.
Show quoted text
> my $ent = MIME::Entity->build( > Type => "text/plain", > Filename => "ñ.txt", > Data => [], > );
Right. It should be: use MIME::Entity; use MIME::Words; my $ent = MIME::Entity->build( Type => "text/plain", Filename => MIME::Words::encode_mimewords("ñ.txt", Charset => 'utf-8'), Data => [], ); [I'm assuming your input file is in UTF-8. If it's in ISO-8859-1, use the appropriate Charset => ... argument.] Then your header ends up looking like this: Content-Disposition: inline; filename="=?UTF-8?Q?=C3=B1?=.txt" Regards, David.
Subject: Re: [rt.cpan.org #66779]
Date: Tue, 29 Mar 2011 23:35:16 +0800
To: "David F. Skoll via RT" <bug-MIME-tools [...] rt.cpan.org>
From: sunnavy <sunnavy [...] gmail.com>
gotcha, so it's not a back compatible change, though I believe the new change makes MIME::Entity more compatible with rfc. thanks for your patience ;) best wishes sunnavy On 11-03-24 13:30, David F. Skoll via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=66779 > > > On Thu, 24 Mar 2011 12:49:23 -0400 > "sunnavy via RT" <bug-MIME-tools@rt.cpan.org> wrote: >
> > hmm, the test file is utf8 encoded.
>
> > my $ent = MIME::Entity->build( > > Type => "text/plain", > > Filename => "ñ.txt", > > Data => [], > > );
> > Right. It should be: > > use MIME::Entity; > use MIME::Words; > > my $ent = MIME::Entity->build( > Type => "text/plain", > Filename => MIME::Words::encode_mimewords("ñ.txt", Charset => 'utf-8'), > Data => [], > ); > > [I'm assuming your input file is in UTF-8. If it's in ISO-8859-1, use > the appropriate Charset => ... argument.] > > Then your header ends up looking like this: > > Content-Disposition: inline; filename="=?UTF-8?Q?=C3=B1?=.txt" > > Regards, > > David. >
Hi, I am resolving this ticket since behaviour in the face of raw UTF-8 headers is not defined (the MIME standards require all headers to be encoded.) Regards, David.