[Mimedefang] Using ARF

Philip Prindeville philipp_subx at redfish-solutions.com
Tue Nov 19 01:07:59 EST 2013


On Nov 18, 2013, at 6:18 PM, David F. Skoll <dfs at roaringpenguin.com> wrote:

> On Mon, 18 Nov 2013 15:25:24 -0700
> Philip Prindeville <philipp_subx at redfish-solutions.com> 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 at 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 at builder ~]$ /tmp/foo.pl
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary

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



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



[philipp at 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 at builder ~]$ /tmp/bar.pl
Content-Type: text/plain

Some random MIME part.
[philipp at 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




More information about the MIMEDefang mailing list