[interchange-cvs] interchange - jon modified lib/Vend/Interpolate.pm

interchange-core@icdevgroup.org interchange-core@icdevgroup.org
Wed Oct 23 12:59:00 2002


User:      jon
Date:      2002-10-23 16:58:13 GMT
Modified:  lib/Vend Interpolate.pm
Log:
Tolerate following previously unallowed constructs:

[if-loop-param fieldname =~ /abc/i]
(and/or options s, m, x)

[if-loop-param fieldname =~ /abc/ ]
(trailing space caused regex compilation to fail before)

Revision  Changes    Path
2.121     +6 -4      interchange/lib/Vend/Interpolate.pm


rev 2.121, prev_rev 2.120
Index: Interpolate.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.120
retrieving revision 2.121
diff -u -u -r2.120 -r2.121
--- Interpolate.pm	23 Oct 2002 16:38:49 -0000	2.120
+++ Interpolate.pm	23 Oct 2002 16:58:12 -0000	2.121
@@ -1,6 +1,6 @@
 # Vend::Interpolate - Interpret Interchange tags
 # 
-# $Id: Interpolate.pm,v 2.120 2002/10/23 16:38:49 jon Exp $
+# $Id: Interpolate.pm,v 2.121 2002/10/23 16:58:12 jon Exp $
 #
 # Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -27,7 +27,7 @@
 require Exporter;
 @ISA = qw(Exporter);
 
-$VERSION = substr(q$Revision: 2.120 $, 10);
+$VERSION = substr(q$Revision: 2.121 $, 10);
 
 @EXPORT = qw (
 
@@ -3248,7 +3248,8 @@
    '!=' => sub { $_[0] != $_[1] },
    '=~' => sub { 
    				 my $re;
-				 $_[1] =~ s:^/(.*)/$:$1:;
+				 $_[1] =~ s:^/(.*)/([imsx]*)\s*$:$1:;
+				 $2 and substr($_[1], 0, 0) = "(?$2)";
    				 eval { $re = qr/$_[1]/ };
 				 if($@) {
 					logError("bad regex %s in if-PREFIX-data", $_[1]);
@@ -3258,7 +3259,8 @@
 				},
    '!~' => sub { 
    				 my $re;
-				 $_[1] =~ s:^/(.*)/$:$1:;
+				 $_[1] =~ s:^/(.*)/([imsx]*)\s*$:$1:;
+				 $2 and substr($_[1], 0, 0) = "(?$2)";
    				 eval { $re = qr/$_[1]/ };
 				 if($@) {
 					logError("bad regex %s in if-PREFIX-data", $_[1]);