[interchange-cvs] interchange - pajamian modified 2 files

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Thu Jan 25 20:50:08 EST 2007


User:      pajamian
Date:      2007-01-26 01:50:08 GMT
Modified:  .        WHATSNEW-5.5
Modified:  code/SystemTag error.coretag
Log:
Fix [error] tag so it does not attempt to replace format codes other than %s in
the text or std_label attributes.  The following test code demonstrates the
problem:

[error name=test set="This is a test error"]
[error name=test std_label=|
    <a href="[area href=formhelp form='
        field=mytable::test
        returnto=this/page
    ']">mylabel</a>
| show_error=1]

In the above test the [area] tag translates this/page in the form attribute to
this%2fpage.  The error tag then sees the %2f as a float specifier and
translates it to this0.000000page, also since the error text itself is gobbled
up the error itself does not display since there is nothing for the later %s
code to match against.  This patch corrects that problem by using a regexp to
substitute the error text instead of an sprintf, and so only the first instance
of %s will be substituted.

Revision  Changes    Path
1.26      +3 -0      interchange/WHATSNEW-5.5


rev 1.26, prev_rev 1.25
Index: WHATSNEW-5.5
===================================================================
RCS file: /var/cvs/interchange/WHATSNEW-5.5,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- WHATSNEW-5.5	18 Jan 2007 19:13:22 -0000	1.25
+++ WHATSNEW-5.5	26 Jan 2007 01:50:08 -0000	1.26
@@ -53,6 +53,9 @@
   &and
   username=unique mytable Sorry, that username is already taken.
 
+* Fix the [error] tag so it does not attempt to replace format specifiers other
+  than %s in the text or std_label attributes.
+
 UserDB
 ------
 



1.6       +4 -3      interchange/code/SystemTag/error.coretag


rev 1.6, prev_rev 1.5
Index: error.coretag
===================================================================
RCS file: /var/cvs/interchange/code/SystemTag/error.coretag,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- error.coretag	8 Nov 2005 18:14:35 -0000	1.5
+++ error.coretag	26 Jan 2007 01:50:08 -0000	1.6
@@ -1,13 +1,13 @@
 # Copyright 2002-2005 Interchange Development Group (http://www.icdevgroup.org/)
 # Licensed under the GNU GPL v2. See file LICENSE for details.
-# $Id: error.coretag,v 1.5 2005/11/08 18:14:35 jon Exp $
+# $Id: error.coretag,v 1.6 2007/01/26 01:50:08 pajamian Exp $
 
 ### This is in package Vend::Interpolate, and may make reference
 ### to variables in that module
 UserTag error               Order        name
 UserTag error               addAttr
 UserTag error               PosNumber    1
-UserTag error               Version      $Revision: 1.5 $
+UserTag error               Version      $Revision: 1.6 $
 UserTag error               Routine      <<EOR
 sub set_error {
 	my ($error, $var, $opt) = @_;
@@ -134,7 +134,8 @@
 	$text = '' unless defined $text;
 	$text .= '%s' unless $text =~ /\%s/;
 	$text = pull_else($text, $found_error);
-	return sprintf($text, $err);
+	$text =~ s/\%s/$err/;
+	return $text;
 }
 
 sub {








More information about the interchange-cvs mailing list