Bug 7230 - Mail::Spamassassin::Message::new fails to handle IO::Lines
Summary: Mail::Spamassassin::Message::new fails to handle IO::Lines
Status: RESOLVED WONTFIX
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: spamassassin (show other bugs)
Version: 3.4.1
Hardware: PC Linux
: P2 minor
Target Milestone: Undefined
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-31 10:50 UTC by anfi
Modified: 2018-08-24 01:31 UTC (History)
2 users (show)



Attachment Type Modified Status Actions Submitter/CLA Status

Note You need to log in before you can comment on or make changes to this bug.
Description anfi 2015-07-31 10:50:41 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) {
Comment 1 Mark Martinec 2015-07-31 12:33:21 UTC
(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 ?
Comment 2 anfi 2015-07-31 12:50:59 UTC
(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.
Comment 3 Mark Martinec 2015-07-31 15:03:02 UTC
> > -    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).
Comment 4 anfi 2015-07-31 16:56:22 UTC
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
Comment 5 Mark Martinec 2015-07-31 17:04:26 UTC
> 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.
Comment 6 Kevin A. McGrail 2018-08-24 01:31:55 UTC
Original reporter not responding to dev