Mailing List Archive

svn commit: r169763 - in /spamassassin/trunk: lib/Mail/SpamAssassin/Conf/Parser.pm t/regexp_valid.t
Author: jm
Date: Wed May 11 21:49:03 2005
New Revision: 169763

URL: http://svn.apache.org/viewcvs?rev=169763&view=rev
Log:
fix /test// case noted by Daryl

Modified:
spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm
spamassassin/trunk/t/regexp_valid.t

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm?rev=169763&r1=169762&r2=169763&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm Wed May 11 21:49:03 2005
@@ -825,6 +825,7 @@
# the start and end, and modifiers at the end if present,
# so we can validate those too.
my $origre = $re;
+ my $safere = $re;
my $mods = '';
if ($re =~ s/^m{//) {
$re =~ s/}([a-z]*)$//; $mods = $1;
@@ -841,6 +842,9 @@
elsif ($re =~ s/^\/(.*)\/([a-z]*)$/$1/) {
$mods = $2;
}
+ else {
+ $safere = "m#".$re."#";
+ }

# now prepend the modifiers, in order to check if they're valid
if ($mods) {
@@ -852,15 +856,19 @@
# security of the regexp. simply using ("" =~ $re) will NOT do that, and
# will therefore open a hole!
if (eval { ("" =~ m#${re}#); 1; }) {
- return 1;
- }
- else {
- my $err = $@;
- $err =~ s/ at .*? line \d+\.\n?//;
- warn "config: invalid regexp for rule $name: $origre: $err\n";
- $self->{conf}->{errors}++;
- return 0;
+
+ # now double-check -- try with the user-supplied delimiters as well
+ my $evalstr = '("" =~ '.$safere.'); 1;';
+ if (eval $evalstr) {
+ return 1;
+ }
}
+
+ my $err = $@;
+ $err =~ s/ at .*? line \d+\.\n?//;
+ warn "config: invalid regexp for rule $name: $origre: $err\n";
+ $self->{conf}->{errors}++;
+ return 0;
}

###########################################################################

Modified: spamassassin/trunk/t/regexp_valid.t
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/t/regexp_valid.t?rev=169763&r1=169762&r2=169763&view=diff
==============================================================================
--- spamassassin/trunk/t/regexp_valid.t (original)
+++ spamassassin/trunk/t/regexp_valid.t Wed May 11 21:49:03 2005
@@ -59,6 +59,6 @@
ok !tryone '/foo(?{1})bar/';
ok !tryone 'm!foo(?{1})bar!';

-# ok !tryone '/test//';
+ok !tryone '/test//';
ok tryone '.*';