spamassassin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From felic...@apache.org
Subject svn commit: r393884 - /spamassassin/trunk/lib/Mail/SpamAssassin/HTML.pm
Date Thu, 13 Apr 2006 18:53:42 GMT
Author: felicity
Date: Thu Apr 13 11:53:37 2006
New Revision: 393884

URL: http://svn.apache.org/viewcvs?rev=393884&view=rev
Log:
make parsing of style="..." generic to any tag (still limited by ok_attributes), move strange
else { if ... } to just be elsif {}, strip out unnecessary variable, etc.

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/HTML.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/HTML.pm
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/lib/Mail/SpamAssassin/HTML.pm?rev=393884&r1=393883&r2=393884&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/HTML.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/HTML.pm Thu Apr 13 11:53:37 2006
@@ -488,11 +488,11 @@
 	  $new{size} = $1;
         }
       }
-      elsif ($tag eq "span" && $name eq "style") {
-        my $style = $new{style} = $attr->{style};
-	my @parts = split(/;/, $style);
+      elsif ($name eq 'style') {
+        $new{style} = $attr->{style};
+	my @parts = split(/;/, $new{style});
 	foreach (@parts) {
-	  if (/\s*(background-)?color:\s*([^;]+)\s*/i) {
+	  if (/^\s*(background-)?color:\s*(.+)\s*$/i) {
 	    my $whcolor = $1 ? 'bgcolor' : 'fgcolor';
 	    my $value = lc $2;
 
@@ -515,26 +515,21 @@
 	      $new{$whcolor} = name_to_rgb($value);
 	    }
 	  }
-	  elsif (/\s*display:\s*none\b/i) {
-	    $new{display} = 'none';
-	    $self->put_results(span_invisible => 1);
-	  }
-	  elsif (/\s*visibility:\s*hidden\b/i) {
-	    $new{visibility} = 'hidden';
-	    $self->put_results(span_invisible => 1);
+	  elsif (/^\s*([a-z_-]+)\s*:\s*(\S.*?)\s*$/i) {
+	    # "display: none", "visibility: hidden", etc.
+	    $new{'style_'.$1} = $2;
 	  }
 	}
       }
+      elsif ($name eq "bgcolor") {
+	# overwrite with hex value, $new{bgcolor} is set below
+        $attr->{bgcolor} = name_to_rgb($attr->{bgcolor});
+      }
       else {
-	if ($name eq "bgcolor") {
-	  # overwrite with hex value, $new{bgcolor} is set below
-	  $attr->{bgcolor} = name_to_rgb($attr->{bgcolor});
-	}
-	else {
-	  # attribute is probably okay
-	  $new{$name} = $attr->{$name};
-	}
+        # attribute is probably okay
+	$new{$name} = $attr->{$name};
       }
+
       if ($new{size} > $self->{max_size}) {
 	$self->{max_size} = $new{size};
       }
@@ -559,8 +554,8 @@
   my $fg = $self->{text_style}[-1]->{fgcolor};
   my $bg = $self->{text_style}[-1]->{bgcolor};
   my $size = $self->{text_style}[-1]->{size};
-  my $display = $self->{text_style}[-1]->{display};
-  my $visibility = $self->{text_style}[-1]->{visibility};
+  my $display = $self->{text_style}[-1]->{style_display};
+  my $visibility = $self->{text_style}[-1]->{style_visibility};
 
   # invisibility
   if (substr($fg,-6) eq substr($bg,-6)) {



Mime
View raw message