Red Hat Bugzilla – Bug 200450
magic open() issue in Mail::Util::read_mbox()
Last modified: 2007-11-30 17:11:38 EST
(Duplicating the bug reported upstream:
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
(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.
Created attachment 133187 [details]
Patch against Mail/Util.pm
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;
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;
will have exactly the opposite restrictions.
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. :-)
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.