[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm

foxr lon-capa-cvs@mail.lon-capa.org
Tue, 17 Oct 2006 09:56:17 -0000


foxr		Tue Oct 17 05:56:17 2006 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  Protect printf_style_subst from formatting items that
  might contain RE special characters. 
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.486 loncom/interface/lonprintout.pm:1.487
--- loncom/interface/lonprintout.pm:1.486	Mon Oct 16 06:32:46 2006
+++ loncom/interface/lonprintout.pm	Tue Oct 17 05:56:16 2006
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.486 2006/10/16 10:32:46 foxr Exp $
+# $Id: lonprintout.pm,v 1.487 2006/10/17 09:56:16 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -62,7 +62,7 @@
 sub printf_style_subst {
     my ($item, $format_string, $repl) = @_;
 
-    while ($format_string =~ /%\d*$item/) {
+    while ($format_string =~ /%\d*\Q$item\E/) {
 	my $start = $-[0];
 	my $end   = $+[0];
 	my $len   = $end - $start;
@@ -72,11 +72,11 @@
 	my $subst = $repl;
 	my $fmt   = substr($format_string, $start, $len);
 	my $size  = $fmt;
-	$size     =~ s/%(\d*)$item/$1/;
+	$size     =~ s/%(\d*)\Q$item\E/$1/;
 	if ($size ne "") {
 	    $subst = substr($subst, 0, $size);
 	}
-	$format_string =~ s/%(\d*)$item/$subst/;
+	$format_string =~ s/%(\d*)\Q$item\E/$subst/;
 
     }