Bug 200450 - magic open() issue in Mail::Util::read_mbox()
Summary: magic open() issue in Mail::Util::read_mbox()
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: perl-MailTools
Version: 5
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Paul Howarth
QA Contact: Fedora Extras Quality Assurance
URL: http://rt.cpan.org//Ticket/Display.ht...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-07-27 19:18 UTC by Steven Pritchard
Modified: 2007-11-30 22:11 UTC (History)
1 user (show)

Fixed In Version: 1.74-2
Clone Of:
Environment:
Last Closed: 2006-08-10 17:08:46 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Patch against Mail/Util.pm (412 bytes, patch)
2006-07-27 19:18 UTC, Steven Pritchard
no flags Details | Diff

Description Steven Pritchard 2006-07-27 19:18:30 UTC
(Duplicating the bug reported upstream:
http://rt.cpan.org//Ticket/Display.html?id=20726 )

I have a script that uses read_mbox() that is choking on a file that has
trailing spaces. Apparently this is expected behavior with the
two-argument form of 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."

(Quoting "perldoc -f open".)

The attached patch (against 1.74) changes the two-argument open() call
to a three-argument open(), which fixes my problem. The only downside
is requiring 5.6.1, since in my reading of perldelta561.pod, that's
where the three-argument open() was introduced.

Comment 1 Steven Pritchard 2006-07-27 19:18:30 UTC
Created attachment 133187 [details]
Patch against Mail/Util.pm

Comment 2 Paul Howarth 2006-07-27 20:07:35 UTC
I'd like to see what upstream thinks of this, as it might be a feature rather
than a bug. The "perldoc -f open" goes on to say:

One should conscientiously choose between the magic and 3-arguments form of open():

    open IN, $ARGV[0];

    will allow the user to specify an argument of the form "rsh cat file â", but
will not work on a filename which happens to have a trailing space, while

    open IN, â<â, $ARGV[0];

    will have exactly the opposite restrictions.


Comment 3 Steven Pritchard 2006-07-27 20:24:51 UTC
If you look at the patch, they are already doing open(FH,"< $file"), which
already rules out any of the other magic ("|" for example).  The only magic it
is doing at this point is stripping whitespace, which screams "bug" to me.

There are several other open() calls which don't include a mode ("<"), most of
which are probably security problems waiting to happen, but your argument makes
some sense for them.  :-)

Comment 4 Paul Howarth 2006-07-28 13:39:54 UTC
Given that upstream's only objection to this is the perl version requirement,
which isn't an issue for Extras, I've added your patch in 1.74-2.


Note You need to log in before you can comment on or make changes to this bug.