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

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Tue Oct 4 15:34:30 EDT 2005


User:      jon
Date:      2005-10-04 19:34:29 GMT
Modified:  lib/Vend Interpolate.pm
Log:
Add new quoting mechanism for the [query] tag, from Kevin Walsh.

An example:

[query
    list=1
    sql=|
        SELECT * FROM products WHERE sku = [sql-quote][cgi sku][/sql-quote]
    |
]
    ...

It uses the query's database handle to access DBI's quote method.

Revision  Changes    Path
2.253     +8 -2      interchange/lib/Vend/Interpolate.pm


rev 2.253, prev_rev 2.252
Index: Interpolate.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.252
retrieving revision 2.253
diff -u -u -r2.252 -r2.253
--- Interpolate.pm	4 Oct 2005 11:11:32 -0000	2.252
+++ Interpolate.pm	4 Oct 2005 19:34:29 -0000	2.253
@@ -1,6 +1,6 @@
 # Vend::Interpolate - Interpret Interchange tags
 # 
-# $Id: Interpolate.pm,v 2.252 2005/10/04 11:11:32 racke Exp $
+# $Id: Interpolate.pm,v 2.253 2005/10/04 19:34:29 jon Exp $
 #
 # Copyright (C) 2002-2005 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
@@ -28,7 +28,7 @@
 require Exporter;
 @ISA = qw(Exporter);
 
-$VERSION = substr(q$Revision: 2.252 $, 10);
+$VERSION = substr(q$Revision: 2.253 $, 10);
 
 @EXPORT = qw (
 
@@ -4393,6 +4393,12 @@
 
 	$opt->{query} = $query
 		if $query;
+
+	$opt->{query} =~ s:
+			\[\Q$opt->{prefix}\E[_-]quote\](.*?)\[/\Q$opt->{prefix}\E[_-]quote\]
+		:
+			$db->quote($1)
+		:xige;
 
 	if (! $opt->{wantarray} and ! defined $MVSAFE::Safe) {
 		my $result = $db->query($opt, $text);








More information about the interchange-cvs mailing list