On Mon, Mar 01, 2010 at 06:05:38PM -0500, Matt Garretson wrote:
My understanding is that the parens cause takeStabAtFilename() to be called in a list context, which in turn for is causing MIME-tools' decode_mimewords() to return an array rather than a scalar. The attached trivial patch to mimedefang.pl.in ditches the parens, causing $fname to be a scalar string as documented within MIMEdefang.

The real problem is that decode_mimewords() should have been forced to scalar context.
Now, the man page for MIME::Words says that forcing decode_mimewords()
to return a scalar is "probably not what you want", but it certainly
is easier to deal with, and it matches the MD's comments and docs.

It's also what previous versions (without the bug) did, so we'll preserve that behaviour for now.

See attached for the new patch.

Cheers,
Dave
--
Dave O'Neill <[email protected]>    Roaring Penguin Software Inc.
+1 (613) 231-6599                        http://www.roaringpenguin.com/
For CanIt technical support, please mail: [email protected]
>From 0d3f3b4761a8b4ac7d58ddff69134577926b7337 Mon Sep 17 00:00:00 2001
From: Dave O'Neill <[email protected]>
Date: Tue, 2 Mar 2010 09:20:47 -0500
Subject: [PATCH] Bugfix: Ensure decode_mimewords() is called in scalar context.

Otherwise, takeStabAtFilename() returns an array, which is unwanted.  And
despite the MIME::Words documentation saying that scalar context of
decode_mimewords() is probably not what we want, it's consistent with previous
versions of MIMEDefang that did not have this bug.
---
 mimedefang.pl.in |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mimedefang.pl.in b/mimedefang.pl.in
index 16302ac..406a721 100755
--- a/mimedefang.pl.in
+++ b/mimedefang.pl.in
@@ -2469,7 +2469,7 @@ sub takeStabAtFilename
 	my $guess = $entity->head->recommended_filename();
 
 	if( defined $guess ) {
-		return decode_mimewords( $guess );
+		return scalar( decode_mimewords( $guess ) );
 	}
 
 	return '';
-- 
1.5.6.5

_______________________________________________
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