On Nov 18, 2013, at 6:18 PM, David F. Skoll <[email protected]> wrote:

> On Mon, 18 Nov 2013 15:25:24 -0700
> Philip Prindeville <[email protected]> wrote:
> 
>> does.  Any chance of fixing new() and build() to allow one to set
>> views like Content-Disposition, Content-Transfer-Encoding,
>> MIME-Version, X-Mailer, etc. to undef and have that do the right
>> thing?
> 
> Maybe... can you detect the difference between Disposition =>
> undef and a missing Disposition?  I have to look into this.

Not sure I understand what you’re asking.  If I don’t set it or if I set it to 
undef, it ends up taking the default value:


[philipp@builder ~]$ cat /tmp/foo.pl
#!/usr/bin/perl 

use strict;
use warnings;

use MIME::Entity;

my $msg = MIME::Entity->build(
        Top => 0,
        Disposition => undef,
        Type => 'text/plain',
        Encoding => undef,
        Data => [
"Some random MIME part.\n",
        ],
);

print $msg->as_string();
[philipp@builder ~]$ /tmp/foo.pl
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary

Some random MIME part.
[philipp@builder ~]$ 



There only way to get the header be omitted altogether is via:



[philipp@builder ~]$ diff -u /tmp/foo.pl /tmp/bar.pl
--- /tmp/foo.pl 2013-11-18 22:58:48.499520090 -0700
+++ /tmp/bar.pl 2013-11-18 22:59:03.651240761 -0700
@@ -15,4 +15,7 @@
        ],
 );
 
+$msg->head()->delete('Content-Disposition');
+$msg->head()->delete('Content-Transfer-Encoding');
+
 print $msg->as_string();
[philipp@builder ~]$ /tmp/bar.pl
Content-Type: text/plain

Some random MIME part.
[philipp@builder ~]$ 


> [...]
> 
>> but also decomposes the Received: header into keyword/value pairs, such as:
> 
> Not a chance.  As Kris Deugau pointed out in his posting, parsing
> Received: headers intelligently is a *LOT* of work given all the
> broken MTAs and MUAs out there.


Well, can we cheat?

Can we start from the premises that (a) you’ll most likely only ever want the 
0th (first) instance, or top-most, Received: line because that’s the only one 
you trust anyway, and that (b) if it’s being called from inside MIMEDefang, 
then the system is locally running either Postfix or Sendmail, and both have 
very predictable Received: formats (assuming no one has mucked with HReceived: 
in their sendmail.cf file)…

-Philip

_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID.  You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list [email protected]
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang

Reply via email to