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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 23 Mar 2006 23:43:14 -0000


albertel		Thu Mar 23 18:43:14 2006 EDT

  Modified files:              
    /loncom/interface	loncommon.pm lonspeller.pm 
  Log:
  - seperate the html encode ant the js_ready bits
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.319 loncom/interface/loncommon.pm:1.320
--- loncom/interface/loncommon.pm:1.319	Tue Mar 21 16:49:30 2006
+++ loncom/interface/loncommon.pm	Thu Mar 23 18:43:13 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.319 2006/03/21 21:49:30 albertel Exp $
+# $Id: loncommon.pm,v 1.320 2006/03/23 23:43:13 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3078,6 +3078,8 @@
                   bgcolor        -> override the default page bg color
                   js_ready       -> return a string ready for being used in 
                                     a javascript writeln
+                  html_encode    -> return a string ready for being used in 
+                                    a html attribute
                   force_register -> if is true will turn on the &bodytag()
                                     $forcereg arg
 
@@ -3107,6 +3109,9 @@
     if ($args->{'js_ready'}) {
 	$result = &js_ready($result);
     }
+    if ($args->{'html_encode'}) {
+	$result = &html_encode($result);
+    }
     return $result;
 }
 
@@ -3121,6 +3126,8 @@
 Inputs:         $args - additional optional args supported are:
                  js_ready     -> return a string ready for being used in 
                                  a javascript writeln
+                 html_encode  -> return a string ready for being used in 
+                                 a html attribute
 =back
 
 =cut
@@ -3133,12 +3140,21 @@
     if ($args->{'js_ready'}) {
 	$result = &js_ready($result);
     }
+    if ($args->{'html_encode'}) {
+	$result = &html_encode($result);
+    }
     return $result;
 }
 
+sub html_encode {
+    my ($result) = @_;
+
+    $result = &HTML::Entities::encode($result,'"');
+    
+    return $result;
+}
 sub js_ready {
     my ($result) = @_;
-    $result = &HTML::Entities::encode($result,'<>&"');
 
     $result =~ s/[\n\r]/ /g;
     $result =~ s/'/\\'/g;	
Index: loncom/interface/lonspeller.pm
diff -u loncom/interface/lonspeller.pm:1.14 loncom/interface/lonspeller.pm:1.15
--- loncom/interface/lonspeller.pm:1.14	Thu Mar 23 17:32:11 2006
+++ loncom/interface/lonspeller.pm	Thu Mar 23 18:43:13 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Interface routines for Aspell
 #
-# $Id: lonspeller.pm,v 1.14 2006/03/23 22:32:11 albertel Exp $
+# $Id: lonspeller.pm,v 1.15 2006/03/23 23:43:13 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -68,11 +68,13 @@
 	    if (($suggestions) && (!$insidelink)) {
 		my $start_page=
 		    &Apache::loncommon::start_page('Speller Suggestions',undef,
-						   {'only_body' => 1,
-						    'js_ready'  => 1,
-						    'bgcolor'   => '#FFFFFF'});
+						   {'only_body'   => 1,
+						    'js_ready'    => 1,
+						    'html_encode' => 1,
+						    'bgcolor'     => '#FFFFFF'});
 		my $end_page=
-		    &Apache::loncommon::end_page({'js_ready'  => 1});
+		    &Apache::loncommon::end_page({'js_ready'    => 1,
+						  'html_encode' => 1,});
 		$output.='<a href="javascript:spellwin=window.open('.
 		    &Apache::lonhtmlcommon::javascript_nothing().
 		    ',\'spellwin\',\'height=140,width=280,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no\');'.