--- loncom/xml/run.pm 2005/11/08 18:59:03 1.53 +++ loncom/xml/run.pm 2008/11/24 18:55:01 1.60 @@ -1,6 +1,6 @@ package Apache::run; # -# $Id: run.pm,v 1.53 2005/11/08 18:59:03 albertel Exp $ +# $Id: run.pm,v 1.60 2008/11/24 18:55:01 jms Exp $ # # Copyright Michigan State University Board of Trustees # @@ -50,6 +50,7 @@ while (!$_LONCAPA_INTERNAL_oldexpression my $__LC__prefix; my $__LC__result; while (1) { + if ($__LC__a =~ m-^&(theta|pi|rho)$-) { last; } { use strict; no strict "vars"; @@ -77,7 +78,7 @@ sub evaluate { my $result = ''; $@=''; $Apache::run::timeout=0; - $main::SIG{'ALRM'} = sub { + local $main::SIG{'ALRM'} = sub { $Apache::run::timeout=1; die("timeout"); }; @@ -115,7 +116,7 @@ sub run { my @result; $@=''; $Apache::run::timeout=0; - $main::SIG{'ALRM'} = sub { + local $main::SIG{'ALRM'} = sub { $Apache::run::timeout=1; die("timeout"); }; @@ -134,13 +135,15 @@ sub run { } my $errormsg='
'.&HTML::Entities::encode($error,'<>&"').' '.
 	    &HTML::Entities::encode($innererror,'<>&"').
-	    '
occured while running
';
+	    '
occurred while running
';
 	$code=&HTML::Entities::encode($code,'<>&"');
 	if ($innererror=~/line (\d+)/) {
 	    my $linenumber=$1;
 	    my @code=split("\n",$code);
-	    $code[$linenumber-1]=''.
-		$code[$linenumber-1].'';
+	    if ($linenumber < scalar(@code)) {
+		$code[$linenumber-1]=''.
+		    $code[$linenumber-1].'';
+	    }
 	    $code=join("\n",@code);
 	}
 	&Apache::lonxml::error($errormsg.$code.'
'); @@ -157,7 +160,8 @@ sub dump { my ($target,$safeeval)=@_; my $dump=''; foreach my $symname (sort keys %{$safeeval->varglob('main::')}) { - if (($symname!~/\027/) && ($symname!~/^\_/) && ($symname!~/\:$/)) { + if (($symname!~ /^(INC|SIG)/) && ($symname!~/\027/) && + ($symname!~/^\_/) && ($symname!~/\:$/)) { my $line; if ($safeeval->reval('defined($'.$symname.')')) { if ($symname =~ /^\w/) { @@ -187,3 +191,29 @@ sub dump { 1; __END__; + +=pod + +=head1 NAME + +Apache::run.pm + +=head1 SYNOPSIS + +Used to prevent poorly written problems from +causing lingering after effects + +This is part of the LearningOnline Network with CAPA project +described at http://www.lon-capa.org. + + +=head1 NOTABLE SUBROUTINES + +=over + +=item run(), dump(), evaluate() + +=back + +=cut +