You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by he...@apache.org on 2023/02/28 10:29:34 UTC

svn commit: r1907911 - in /spamassassin/trunk/lib/Mail/SpamAssassin: Message.pm Message/Node.pm

Author: hege
Date: Tue Feb 28 10:29:33 2023
New Revision: 1907911

URL: http://svn.apache.org/viewvc?rev=1907911&view=rev
Log:
Bug 6260 - text attachments are not scanned if the MIME type is APPLICATION/OCTET-STREAM

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm?rev=1907911&r1=1907910&r2=1907911&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm Tue Feb 28 10:29:33 2023
@@ -759,6 +759,7 @@ sub finish {
     delete $part->{'invisible_rendered'};
     delete $part->{'type'};
     delete $part->{'rendered_type'};
+    delete $part->{'effective_type'};
 
     # if there are children nodes, add them to the queue of nodes to clean up
     if (exists $part->{'body_parts'}) {
@@ -1350,11 +1351,13 @@ sub get_decoded_body_text_array {
   my $scansize = $self->{rawbody_part_scan_size};
 
   # Find all parts which are leaves
-  my @parts = $self->find_parts(qr/^(?:text|message)\b/,1);
+  my @parts = $self->find_parts(qr/./,1);
   return $self->{text_decoded} unless @parts;
 
   # Go through each part
   for(my $pt = 0 ; $pt <= $#parts ; $pt++ ) {
+    # skip non-text parts (Bug 6439)
+    next unless $parts[$pt]->effective_type() =~ /^(?:text|message)\b/;
     # bug 4843: skip text/calendar parts since they're usually an attachment
     # and not displayed
     next if ($parts[$pt]->{'type'} eq 'text/calendar');

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm?rev=1907911&r1=1907910&r2=1907911&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm Tue Feb 28 10:29:33 2023
@@ -686,6 +686,19 @@ sub _normalize {
   return $rv;
 }
 
+# Parse effective content type (Bug 6260, 6439)
+sub effective_type {
+  my ($self) = @_;
+  if (!exists $self->{'effective_type'}) {
+    if (($self->{'name'}||'') =~ /\.s?html?$/i) {
+      $self->{'effective_type'} = 'text/html';
+    } else {
+      $self->{'effective_type'} = $self->{'type'};
+    }
+  }
+  return $self->{'effective_type'};
+}
+
 =item rendered()
 
 rendered() takes the given text/* type MIME part, and attempts to
@@ -708,7 +721,7 @@ sub rendered {
   # Note: for bug 4843, make sure to skip text/calendar parts
   # we also want to skip things like text/x-vcard
   # text/x-aol is ignored here, but looks like text/html ...
-  my $type = lc $self->{'type'};
+  my $type = $self->effective_type();
   unless ($type eq 'text/plain' || $type eq 'text/html') {
     return (undef,undef);
   }