Skip Menu |

This queue is for tickets about the MailTools CPAN distribution.

Report information
The Basics
Id: 105254
Status: rejected
Priority: 0/
Queue: MailTools

People
Owner: Nobody in particular
Requestors: kentarou [...] right.jp
Cc:
AdminCc:

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



Subject: change request about Mail/Header.pm.
Date: Tue, 16 Jun 2015 11:20:12 +0900
To: <bug-MailTools [...] rt.cpan.org>
From: kentarou 中村 健太郎 <kentarou [...] right.jp>
Dear Developers, First, I'm Japanese. I'm not good at English very much. If there are some not polite or not good expressions, please ask me. Problem: When we send e-mail from perl, the below message came. Show quoted text
> Bad RFC822 field name 'Content-Disposition' > at /usr/local/share/perl5/MIME/Entity.pm line 642.
Same script worked in our old server, however it doesn't not worked in our new server. Environment: OS: Red Hat Enterprise Linux Server release 7.0 (Maipo) Perl: perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi. Background: In UTF-8 environment, the perl regular expression is not understandable for me in new server. For example... use encoding 'utf8', STDIN=>'utf8', STDOUT=>'utf8'; $s = "position"; $F = '[^\x00-\x1f\x7f-\xff :]+'; print "no opt:".( $s =~ /^$F$/ )."\n"; # it's match. print "opt i:".( $s =~ /^$F$/i )."\n"; # it's not match. When I executed the script in rhel 5.5, perl 5.8.8, both matched. However I executed the script in rhel 7.0, perl 5.16.3, the last regular expression was not matched. I expect the regular expression should not be affected with option "i". Solved-diff: 148c148 < ($tag) = $line =~ /^($FIELD_NAME|From )/oi --- Show quoted text
> ($tag) = $line =~ /^($FIELD_NAME|From )/o
170c170 < defined $ctag && $ctag =~ /^($FIELD_NAME|From )/oi --- Show quoted text
> defined $ctag && $ctag =~ /^($FIELD_NAME|From )/o
273c273 < { my $tag = _tag_case +($ln =~ /^($FIELD_NAME|From )/oi)[0]; --- Show quoted text
> { my $tag = _tag_case +($ln =~ /^($FIELD_NAME|From )/o)[0];
Subject: Re: [rt.cpan.org #105254] change request about Mail/Header.pm.
Date: Tue, 16 Jun 2015 09:50:36 +0200
To: kentarou 中村 健太郎 via RT <bug-MailTools [...] rt.cpan.org>
From: Mark Overmeer <solutions [...] overmeer.net>
* kentarou 中村 健太郎 via RT (bug-MailTools@rt.cpan.org) [150616 02:21]: Show quoted text
> Mon Jun 15 22:20:26 2015: Request 105254 was acted upon. > Transaction: Ticket created by kentarou@right.jp > Queue: MailTools > Subject: change request about Mail/Header.pm. > > First, I'm Japanese. > I'm not good at English very much.
Hi Kentarou, No problem to understand. I am always glad that my native language (Dutch) is much close to English... Show quoted text
> Problem: > When we send e-mail from perl, the below message came.
> > Bad RFC822 field name 'Content-Disposition' > > at /usr/local/share/perl5/MIME/Entity.pm line 642.
Show quoted text
> use encoding 'utf8', STDIN=>'utf8', STDOUT=>'utf8';
I think this has something to do with this section in the manual page of "encoding" This pragma also affects encoding of the 0x80..0xFF code point range: normally characters in that range are left as eight-bit bytes (unless they are combined with characters with code points 0x100 or larger, in which case all characters need to become UTF-8 encoded), but if the "encoding" pragma is present, even the 0x80..0xFF range always gets UTF-8 encoded. After all, the best thing about this pragma is that you don't have to resort to \x{....} just to spell your name in a native encoding ... The idea of use of unicode has changed a lot since 5.8. Now, we only use: use utf8; use open ':encoding(utf8)'; I am not sure that this global "open" option is handled correctly. MimeTools is a very very old module. Of course, the mail headers are ASCII. The email body can be in any encoding (Content-Type attribute charset) So, the message must be read in ":raw" mode. Show quoted text
> $s = "position"; > $F = '[^\x00-\x1f\x7f-\xff :]+'; > print "no opt:".( $s =~ /^$F$/ )."\n"; # it's match. > print "opt i:".( $s =~ /^$F$/i )."\n"; # it's not match.
I can reproduce this. Show quoted text
> I expect the regular expression should not be affected with option "i".
Case-insensitivity is required, so the 'i' cannot be removed. Show quoted text
> < defined $ctag && $ctag =~ /^($FIELD_NAME|From )/oi
> > defined $ctag && $ctag =~ /^($FIELD_NAME|From )/o
A fix could be defined $ctag && lc($ctag) =~ /^($FIELD_NAME|From )/o So, my advice to you: . when you have non-ascii in your source file, set 'use utf8'; . for each input and output in your program, figure-out which charset is coming in or out, and specify that explicitly on that location (no globals via "use open" or "use encoding") Like this: open(my $fh, "<:encoding(UTF-8)", $filename) I will not change MailTools, afraid it will break someones ancient installation. Use MailBox if you write a new application. -- Thank you for your report, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
Subject: RE: [rt.cpan.org #105254] change request about Mail/Header.pm.
Date: Tue, 16 Jun 2015 18:02:41 +0900
To: <bug-MailTools [...] rt.cpan.org>
From: kentarou 中村 健太郎 <kentarou [...] right.jp>
Thank you very much for your quickly advise. We fixed the problem with the below pragma. use utf8; use open ':encoding(utf8)'; binmode STDOUT, ':encoding(utf8)'; And I didn't realized MimeTools was so old. We use MimeTools only once in our Library. So we are going to translate to use MailBox. Thank you.
The solution is to avoid 'use encoding'