Skip Menu |

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

Report information
The Basics
Id: 35979
Status: resolved
Priority: 0/
Queue: MIME-Lite

People
Owner: Nobody in particular
Requestors: dom [...] cpan.org
Cc: gregoa [...] cpan.org
AdminCc:

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



Subject: "MIME-Version: 1.0" hardwired
As reported in Debian's BTS: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=460395 "[...]despite the man page saying Giving VALUE as the empty string adds an invisible placeholder to the header, which can be used to suppress the output of the "Con- tent-*" fields or the special "MIME-Version" field. When sup- pressing fields, you should use replace() instead of add(): $msg->replace("Content-disposition" => ""); Note: add() is probably going to be more efficient than "replace()", so you're better off using it for most applications if you are certain that you don't need to delete() the field first. There is _no way_ you will get "MIME-Version: 1.0" out. It is hardwired. use MIME::Lite; $m="MIME-Version"; $msg = MIME::Lite->new( Type => "multipart/digest" ); $msg->attr($m => "qqq"); $msg->replace($m => undef); $msg->replace($m => ""); $msg->replace($m => "zzz"); $msg->attr($m => ""); $msg->attr($m => undef); $msg->attr($m => "uuu"); $msg->add($m => "kkk"); $msg->scrub([$m]); $msg->delete($m); $msg->print( \*STDOUT ); One even sees warnings, Explicitly setting a MIME header field (mime-version) is dangerous: use the attr() method instead. as if it worked. Why would one want to remove MIME-Version? How about here on the man page: Attach a pre-prepared part to a message ### Create a standalone part: $part = MIME::Lite->new(... ### Attach it to any message: $msg->attach($part); Attempt to get it out of $part before attaching. Anyways, the only way to get it out of an attachment is $msg->attach( Type ... );"
While I will cede that this is a problem, I still don't understand why you'd want to get rid of that field. An attached file's part may have a MIME-Version header. This is not a problem, semantically. -- rjbs
FYI, I am unlikely to fix this bug on my own. Patches welcome. -- rjbs
From: fschlich [...] zedat.fu-berlin.de
I think the problem is in top_level(), where 'MIME-Version' is set in proper case, whereas in the rest of the module, attribute tags are lowercased (see e.g. add() or attr()) and then converted back to proper case for printing in fields_as_string(). Looking closely at the output of the bug reporter's code, one will notice *two* 'MIME-Version' headers as a reflection of this inconsistency. I offer the following patch as a fix: --- a/MIME/Lite.pm +++ b/MIME/Lite.pm @@ -1146,12 +1146,12 @@ sub top_level { my ( $self, $onoff ) = @_; my $attrs = $self->{Attrs}; if ($onoff) { - $attrs->{'MIME-Version'} = '1.0'; + $attrs->{'mime-version'} = '1.0'; my $uses = ( @Uses ? ( "(" . join( "; ", @Uses ) . ")" ) : '' ); $self->replace( 'X-Mailer' => "MIME::Lite $VERSION $uses" ) unless $VANILLA; } else { - delete $attrs->{'MIME-Version'}; + delete $attrs->{'mime-version'}; $self->delete('X-Mailer'); } } Florian
On Tue Jun 07 16:23:30 2011, fschlich wrote: Show quoted text
> I offer the following patch as a fix:
We have been applying this patch on Debian for 10 months, no complain so far. Ricardo, what do you think?
On 2012-07-05 19:55:33, intrigeri@boum.org wrote: Show quoted text
> On Tue Jun 07 16:23:30 2011, fschlich wrote:
> > I offer the following patch as a fix:
> > We have been applying this patch on Debian for 10 months, no complain so > far. > > Ricardo, what do you think?
Looks good. I've added it to git at https://github.com/rjbs/mime-lite Can I get a test from some interested party? With a test, I will ship immediately. -- rjbs
From: fschlich [...] zedat.fu-berlin.de
On Thu Jul 05 20:24:51 2012, RJBS wrote: Show quoted text
> Can I get a test from some interested party? With a test, I will ship > immediately.
here you go: #!/usr/bin/perl use strict; use warnings; use lib "lib"; use MIME::Lite; use Test::More; my $msg = MIME::Lite->new( Type => "multipart/digest" ); $msg->attr( 'MIME-Version' => 'qqq' ); my $str = $msg->as_string; like($str, qr/MIME-Version: qqq/, '"MIME-Version" header has been set to qqq'); unlike($str, qr/MIME-Version: 1\.0/, 'default header "MIME-Version: 1.0" has been overwritten and is no longer found'); is($str =~ s/MIME-Version: /counted/g, 1, 'only one MIME-Version header present'); done_testing(); Florian
Subject: Re: [rt.cpan.org #35979] "MIME-Version: 1.0" hardwired
Date: Thu, 26 Jul 2012 23:27:08 -0400
To: Florian via RT <bug-MIME-Lite [...] rt.cpan.org>
From: Ricardo Signes <rjbs [...] cpan.org>
* Florian via RT <bug-MIME-Lite@rt.cpan.org> [2012-07-19T05:30:26] Show quoted text
> On Thu Jul 05 20:24:51 2012, RJBS wrote:
> > Can I get a test from some interested party? With a test, I will ship > > immediately.
> > here you go:
Fantastic, thanks. I'll try to get this all integrated tomorrow! -- rjbs
Download signature.asc
application/pgp-signature 490b

Message body not shown because it is not plain text.

Sorry this took more than a day. I'll get to your other patches soon, too. -- rjbs