You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by bu...@bugzilla.spamassassin.org on 2007/01/10 06:30:36 UTC
[Bug 5288] New: ArchiveIterator fails on filenames with leading spaces
http://issues.apache.org/SpamAssassin/show_bug.cgi?id=5288
Summary: ArchiveIterator fails on filenames with leading spaces
Product: Spamassassin
Version: 3.1.7
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P5
Component: Libraries
AssignedTo: dev@spamassassin.apache.org
ReportedBy: steffen@ics.mq.edu.au
While trying to run sa-learn on some mailboxes with leading spaces in their
names, I discovered that ArchiveIterator.pm fails to open such mailboxes because
it uses the 2 argument version of open() which strips leading whitespace from
filenames.
The attached patch fixes this fixes by prepending ./ to such filenames (as per
the Camel book)
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
[Bug 5288] ArchiveIterator fails on filenames with leading spaces
Posted by bu...@bugzilla.spamassassin.org.
http://issues.apache.org/SpamAssassin/show_bug.cgi?id=5288
------- Additional Comments From steffen@ics.mq.edu.au 2007-01-09 21:46 -------
indeed, it would probably be better to use the 3 argument version of open() in
mail_open (execpt in the .gz/.bz2 cases)
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
[Bug 5288] [review] ArchiveIterator fails on filenames with leading spaces
Posted by bu...@bugzilla.spamassassin.org.
http://issues.apache.org/SpamAssassin/show_bug.cgi?id=5288
felicity@apache.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #3821 is|0 |1
obsolete| |
------- Additional Comments From felicity@apache.org 2007-01-09 22:27 -------
Created an attachment (id=3823)
--> (http://issues.apache.org/SpamAssassin/attachment.cgi?id=3823&action=view)
suggested patch
This patch backports 3.2's mail_open function, so it includes the fix for this
bug as well as bug 5249 (use binmode after opening the file).
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
[Bug 5288] [review] ArchiveIterator fails on filenames with leading spaces
Posted by bu...@bugzilla.spamassassin.org.
http://issues.apache.org/SpamAssassin/show_bug.cgi?id=5288
------- Additional Comments From steffen@ics.mq.edu.au 2007-01-09 23:48 -------
there is one thing your patch does not take into account: opening of STDIN via a
filename of '-', which the 2 arg version of open() does. This breaks e.g. piping
mail into spamassassin...
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
[Bug 5288] [review] ArchiveIterator fails on filenames with leading spaces
Posted by bu...@bugzilla.spamassassin.org.
http://issues.apache.org/SpamAssassin/show_bug.cgi?id=5288
------- Additional Comments From jm@jmason.org 2007-02-02 02:56 -------
+1
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
[Bug 5288] ArchiveIterator fails on filenames with leading spaces
Posted by bu...@bugzilla.spamassassin.org.
http://issues.apache.org/SpamAssassin/show_bug.cgi?id=5288
felicity@apache.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|Undefined |3.2.0
------- Additional Comments From felicity@apache.org 2007-01-09 21:40 -------
Hrm, interesting! I didn't know about this "special" behavior of open()...
Unfortunately, both leading and trailing whitespace is removed, and redirection
characters are honored, which is bad. So we'll have to deal with this a little
more directly.
If anyone's interested, here's a snippet from "perldoc -f open":
The filename passed to 2-argument (or 1-argument) form of
open() will have leading and trailing whitespace deleted, and
the normal redirection characters honored. This property,
known as "magic open", can often be used to good effect. A
user could specify a filename of "rsh cat file |", or you could
change certain filenames as needed:
$filename =~ s/(.*\.gz)\s*$/gzip -dc < $1|/;
open(FH, $filename) or die "Can't open $filename: $!";
Use 3-argument form to open a file with arbitrary weird charac-
ters in it,
open(FOO, '<', $file);
otherwise it's necessary to protect any leading and trailing
whitespace:
$file =~ s#^(\s)#./$1#;
open(FOO, "< $file\0");
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
[Bug 5288] [review] ArchiveIterator fails on filenames with leading spaces
Posted by bu...@bugzilla.spamassassin.org.
http://issues.apache.org/SpamAssassin/show_bug.cgi?id=5288
------- Additional Comments From felicity@apache.org 2007-01-09 23:59 -------
(In reply to comment #7)
> there is one thing your patch does not take into account: opening of STDIN via a
> filename of '-', which the 2 arg version of open() does. This breaks e.g. piping
> mail into spamassassin...
Actually, ArchiveIterator doesn't support "-", so that's not an issue.
spamassassin and sa-learn handle reading from STDIN and creating a temp file,
which is what's actually used. (bug 5145 dealt with this for 3.1.8 -- you're
probably right that things would break if you only apply this patch to 3.1.7)
:)
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
[Bug 5288] ArchiveIterator fails on filenames with leading spaces
Posted by bu...@bugzilla.spamassassin.org.
http://issues.apache.org/SpamAssassin/show_bug.cgi?id=5288
------- Additional Comments From steffen@ics.mq.edu.au 2007-01-09 21:31 -------
Created an attachment (id=3821)
--> (http://issues.apache.org/SpamAssassin/attachment.cgi?id=3821&action=view)
patch to ArchiveIterator.pm fixing the issue as described
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
[Bug 5288] [review] ArchiveIterator fails on filenames with leading spaces
Posted by bu...@bugzilla.spamassassin.org.
http://issues.apache.org/SpamAssassin/show_bug.cgi?id=5288
parkerm@pobox.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status Whiteboard|needs 2 votes |needs 1 vote
------- Additional Comments From parkerm@pobox.com 2007-01-31 20:29 -------
+1
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
[Bug 5288] [review] ArchiveIterator fails on filenames with leading spaces
Posted by bu...@bugzilla.spamassassin.org.
http://issues.apache.org/SpamAssassin/show_bug.cgi?id=5288
felicity@apache.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Status Whiteboard|needs 1 vote |ready to commit
------- Additional Comments From felicity@apache.org 2007-02-04 11:40 -------
Sending lib/Mail/SpamAssassin/ArchiveIterator.pm
Transmitting file data .
Committed revision 503461.
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
[Bug 5288] ArchiveIterator fails on filenames with leading spaces
Posted by bu...@bugzilla.spamassassin.org.
http://issues.apache.org/SpamAssassin/show_bug.cgi?id=5288
------- Additional Comments From felicity@apache.org 2007-01-09 22:12 -------
(In reply to comment #3)
> indeed, it would probably be better to use the 3 argument version of open() in
> mail_open (execpt in the .gz/.bz2 cases)
Actually we need to do it there as well to deal with the whitespace issue. I
have a patch that I'm almost done with which does this. :)
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
[Bug 5288] [review] ArchiveIterator fails on filenames with leading spaces
Posted by bu...@bugzilla.spamassassin.org.
http://issues.apache.org/SpamAssassin/show_bug.cgi?id=5288
------- Additional Comments From steffen@ics.mq.edu.au 2007-01-10 00:02 -------
yes, the patch breaks 3.1.7, which is how I found out about it...
the following extra condition at the top of mail_open fixes it:
if ($file eq "-") {
$mode = '<&';
@expr = ( "STDIN" );
}
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
[Bug 5288] [review] ArchiveIterator fails on filenames with leading spaces
Posted by bu...@bugzilla.spamassassin.org.
http://issues.apache.org/SpamAssassin/show_bug.cgi?id=5288
felicity@apache.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status Whiteboard| |needs 2 votes
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
[Bug 5288] [review] ArchiveIterator fails on filenames with leading spaces
Posted by bu...@bugzilla.spamassassin.org.
http://issues.apache.org/SpamAssassin/show_bug.cgi?id=5288
felicity@apache.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|ArchiveIterator fails on |[review] ArchiveIterator
|filenames with leading |fails on filenames with
|spaces |leading spaces
Target Milestone|3.2.0 |3.1.8
------- Additional Comments From felicity@apache.org 2007-01-09 22:26 -------
ok, patch applied to 3.2:
Sending lib/Mail/SpamAssassin/ArchiveIterator.pm
Transmitting file data .
Committed revision 494733.
will put up a 3.1 version shortly
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
[Bug 5288] ArchiveIterator fails on filenames with leading spaces
Posted by bu...@bugzilla.spamassassin.org.
http://issues.apache.org/SpamAssassin/show_bug.cgi?id=5288
steffen@ics.mq.edu.au changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #3821|patch to ArchiveIterator.pm |patch to
description|fixing the issue as |lib/Mail/SpamAssassin/Archiv
|described |eIterator.pm
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.