SA Bugzilla – Bug 7230
Mail::Spamassassin::Message::new fails to handle IO::Lines
Last modified: 2018-08-24 01:31:55 UTC
Mail::Spamassassin::Message::new(...) fails to process IO::File input. It fails with the following message: Can't locate object method "FILENO" via package "IO::Lines" at /usr/share/perl5/Mail/SpamAssassin/Message.pm line 160 159 elsif (ref($message) eq 'GLOB' || ref($message) =~ /^IO::/) { 160 if (defined fileno $message) {
(In reply to anfi from comment #0) > Mail::Spamassassin::Message::new(...) fails to process IO::File input. > > It fails with the following message: > Can't locate object method "FILENO" via package "IO::Lines" at > /usr/share/perl5/Mail/SpamAssassin/Message.pm line 160 > > 159 elsif (ref($message) eq 'GLOB' || ref($message) =~ /^IO::/) { > 160 if (defined fileno $message) { Try: --- lib/Mail/SpamAssassin/Message.pm (revision 1693581) +++ lib/Mail/SpamAssassin/Message.pm (working copy) @@ -159,3 +159,3 @@ elsif (ref($message) eq 'GLOB' || ref($message) =~ /^IO::/) { - if (defined fileno $message) { + if (!$message->UNIVERSAL::can("fileno") || defined fileno $message) { What interface module to SpamAssassin are you using? Is it a MIMEDefang ?
(In reply to Mark Martinec from comment #1) > (In reply to anfi from comment #0) > > Mail::Spamassassin::Message::new(...) fails to process IO::File input. > > > > It fails with the following message: > > Can't locate object method "FILENO" via package "IO::Lines" at > > /usr/share/perl5/Mail/SpamAssassin/Message.pm line 160 > > > > 159 elsif (ref($message) eq 'GLOB' || ref($message) =~ /^IO::/) { > > 160 if (defined fileno $message) { > > Try: > > --- lib/Mail/SpamAssassin/Message.pm (revision 1693581) > +++ lib/Mail/SpamAssassin/Message.pm (working copy) > @@ -159,3 +159,3 @@ > elsif (ref($message) eq 'GLOB' || ref($message) =~ /^IO::/) { > - if (defined fileno $message) { > + if (!$message->UNIVERSAL::can("fileno") || defined fileno $message) { AFAIK will make SA read empty message without OBVIOUS explanation. IMHO it will make things worse without "else" part for "fileno if". > What interface module to SpamAssassin are you using? > Is it a MIMEDefang ? I have tested Mail::Box modules in my perl scripts for maildir processing.
> > - if (defined fileno $message) { > > + if (!$message->UNIVERSAL::can("fileno") || defined fileno $message) { > > AFAIK will make SA read empty message without OBVIOUS explanation. > IMHO it will make things worse without "else" part for "fileno if". If the IO:: module does not implement the fileno method (like the IO::Lines, where a file handle is not associated with any file descriptor), it makes no sense to test for a presence of a file descriptor. If reading fails for some reason in sysread, it will be detected and reported when it happens. If the IO:: module _does_ implement the fileno method, then the diff above makes no change the current behaviour. (I don't know why a test for a fileno was there in the first place, I'm just leaving a status quo. To which you are probably referring, but that would be an unrelated issue).
I would like to make Mail::Spamassassin::Message::new process IO::Lines correctly. It is nor important for me how Mail::Spamassassin::Message::new fails to handle IO::Lines. P.S. Sorry for original misleading bug title/summary
> I would like to make Mail::Spamassassin::Message::new process IO::Lines > correctly. It is nor important for me how Mail::Spamassassin::Message::new > fails to handle IO::Lines. Indeed. Why do you think the suggested diff and the argument below does not do exactly that: | If the IO:: module does not implement the fileno method (like | the IO::Lines, where a file handle is not associated with any | file descriptor), it makes no sense to test for a presence of | a file descriptor.
Original reporter not responding to dev