--- loncom/xml/run.pm 2002/04/10 14:46:30 1.25 +++ loncom/xml/run.pm 2002/04/10 15:22:02 1.26 @@ -1,6 +1,6 @@ package Apache::run; # -# $Id: run.pm,v 1.25 2002/04/10 14:46:30 matthew Exp $ +# $Id: run.pm,v 1.26 2002/04/10 15:22:02 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -25,6 +25,8 @@ package Apache::run; # http://www.lon-capa.org/ # +use HTML::Entities; + $Apache::run::EVALUATE_STRING=<<'ENDEVALUATE'; my %_LONCAPA_INTERNAL_oldexpressions=(); my $i=0; @@ -44,11 +46,14 @@ sub evaluate { $safeeval->reval('{'.$decls.';$_=<<\'EXPRESSION\';'."\n".$expression. "\n".'EXPRESSION'."\n".$EVALUATE_STRING.'}'); # $safeeval->reval('{'.$decls.';<< &evaluate(q|'.$expression.'|);}'); + my $error=$@; if ($@ eq '') { $result = $safeeval->reval('return $_;'); chomp $result; } else { - &Apache::lonxml::error("substitution on:$expression:with:$decls:caused $@"); + &Apache::lonxml::error('substitution on
'.$expression.
+			   '
with
'.$decls.
+			   '
caused
'.$error);
   }  
   return $result
 }
@@ -58,9 +63,11 @@ sub run {
 #  print "inside run\n";
   $@='';
   my (@result)=$safeeval->reval($code);
-  if ($@ ne '' && !$hideerrors) {
-    # Put in newline to make display of code easier to read.
-    &Apache::lonxml::error(":$@: occured while running :\n$code");
+  my $error=$@;
+  if ($error ne '' && !$hideerrors) {
+    &Apache::lonxml::error('
'.&HTML::Entities::encode($error).
+			   '
occured while running
'.
+			   &HTML::Entities::encode($code).'
'); } if ( $#result < '1') { return $result[0];