You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by fe...@apache.org on 2006/05/24 19:18:36 UTC

svn commit: r409210 - in /spamassassin/branches/3.1/lib/Mail/SpamAssassin: Conf.pm PerMsgStatus.pm

Author: felicity
Date: Wed May 24 10:18:36 2006
New Revision: 409210

URL: http://svn.apache.org/viewvc?rev=409210&view=rev
Log:
bug 4793: when replacing tags in a message (_TAG_), leave the tags that don't exist alone instead of just removing them

Modified:
    spamassassin/branches/3.1/lib/Mail/SpamAssassin/Conf.pm
    spamassassin/branches/3.1/lib/Mail/SpamAssassin/PerMsgStatus.pm

Modified: spamassassin/branches/3.1/lib/Mail/SpamAssassin/Conf.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/3.1/lib/Mail/SpamAssassin/Conf.pm?rev=409210&r1=409209&r2=409210&view=diff
==============================================================================
--- spamassassin/branches/3.1/lib/Mail/SpamAssassin/Conf.pm (original)
+++ spamassassin/branches/3.1/lib/Mail/SpamAssassin/Conf.pm Wed May 24 10:18:36 2006
@@ -2615,9 +2615,7 @@
 =head1 TEMPLATE TAGS
 
 The following C<tags> can be used as placeholders in certain options.
-They will be replaced by the corresponding value when they are used.  Keep in
-mind that anything that looks like a tag will be replaced (C<_STRING_>), even
-in the middle of other characters (C<FOR_STRING_EXAMPLE>).
+They will be replaced by the corresponding value when they are used.
 
 Some tags can take an argument (in parentheses). The argument is
 optional, and the default is shown below.
@@ -2663,6 +2661,10 @@
  _REPORT_          terse report of tests hit (for header reports)
  _SUMMARY_         summary of tests hit for standard report (for body reports)
  _CONTACTADDRESS_  contents of the 'report_contact' setting
+
+If a tag reference uses the name of a tag which is not in this list or defined
+by a loaded plugin, the reference will be left intact and not replaced by any
+value.
 
 The C<HAMMYTOKENS> and C<SPAMMYTOKENS> tags have an optional second argument
 which specifies a format.  See the B<HAMMYTOKENS/SPAMMYTOKENS TAG FORMAT>

Modified: spamassassin/branches/3.1/lib/Mail/SpamAssassin/PerMsgStatus.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/3.1/lib/Mail/SpamAssassin/PerMsgStatus.pm?rev=409210&r1=409209&r2=409210&view=diff
==============================================================================
--- spamassassin/branches/3.1/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/branches/3.1/lib/Mail/SpamAssassin/PerMsgStatus.pm Wed May 24 10:18:36 2006
@@ -1008,7 +1008,15 @@
   my $self = shift;
   my $text = shift;
 
-  $text =~ s/_(\w+?)(?:\((.*?)\))?_/${\($self->_get_tag($1,$2))}/g;
+  # default to leaving the original string in place, if we cannot find
+  # a tag for it (bug 4793)
+  $text =~ s{(_(\w+?)(?:\((.*?)\))?_)}{
+	my $full = $1;
+        my $tag = $2;
+        my $result = $self->_get_tag($tag,$3);
+        (defined $result) ? $result : $full;
+      }ge;
+
   return $text;
 }
 
@@ -1101,6 +1109,8 @@
 C<Mail::SpamAssassin::Conf>'s C<TEMPLATE TAGS> section for more details on
 tags.
 
+C<undef> will be returned if a tag by that name has not been defined.
+
 =cut
 
 sub get_tag {
@@ -1246,20 +1256,21 @@
 
           );
 
+  my $data;
   if (exists $tags{$tag}) {
-    return $tags{$tag}->(@_);
+    $data = $tags{$tag}->(@_);
   }
-  elsif ($self->{tag_data}->{$tag}) {
-    my $data = $self->{tag_data}->{$tag};
+  elsif (exists($self->{tag_data}->{$tag})) {
+    $data = $self->{tag_data}->{$tag};
     if (ref $data eq 'CODE') {
-      return $data->(@_);
-    } else {
-      return $data;
+      $data = $data->(@_);
     }
   }
   else {
-    return "";
+    return;
   }
+  $data = "" unless defined $data;
+  return $data;
 }
 
 ###########################################################################