--- loncom/xml/run.pm 2003/03/25 03:00:31 1.33 +++ loncom/xml/run.pm 2003/06/09 21:45:23 1.38 @@ -1,6 +1,6 @@ package Apache::run; # -# $Id: run.pm,v 1.33 2003/03/25 03:00:31 albertel Exp $ +# $Id: run.pm,v 1.38 2003/06/09 21:45:23 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -47,14 +47,16 @@ sub evaluate { $Apache::run::timeout=1; die("timeout"); }; + my $innererror; eval { - alarm(Apache->request->server->timeout); + alarm($Apache::lonnet::perlvar{'lonScriptTimeout'}); $safeeval->reval('{'.$decls.';$_=<<\'EXPRESSION\';'."\n".$expression. "\n".'EXPRESSION'."\n".$EVALUATE_STRING.'}'); + $innererror=$@; alarm(0); }; my $error=$@; - if ($error eq '' && !$Apache::run::timeout) { + if ($error eq '' && $innererror eq '' && !$Apache::run::timeout) { $result = $safeeval->reval('return $_;'); chomp $result; } else { @@ -62,9 +64,14 @@ sub evaluate { $error = 'Code ran too long. It ran for more than '. Apache->request->server->timeout.' seconds'; } - &Apache::lonxml::error('substitution on
'.$expression. - 'with
'.$decls. - 'caused
'.$error); + &Apache::lonxml::error('substitution on'. + &HTML::Entities::encode($expression). + 'with'. + &HTML::Entities::encode($decls). + 'caused'. + &HTML::Entities::encode($error).' '. + &HTML::Entities::encode($innererror). + ''); } return $result } @@ -78,18 +85,21 @@ sub run { $Apache::run::timeout=1; die("timeout"); }; + my $innererror; eval { - alarm(Apache->request->server->timeout); + alarm($Apache::lonnet::perlvar{'lonScriptTimeout'}); @result=$safeeval->reval($code); + $innererror=$@; alarm(0); }; my $error=$@; - if (($Apache::run::timeout || $error ne '') && !$hideerrors) { + if (($Apache::run::timeout || $error ne '' || $innererror ne '') && !$hideerrors) { if ($Apache::run::timeout) { $error = 'Code ran too long. It ran for more than '. Apache->request->server->timeout.' seconds'; } - &Apache::lonxml::error(''.&HTML::Entities::encode($error). + &Apache::lonxml::error(''.&HTML::Entities::encode($error).' '. + &HTML::Entities::encode($innererror). 'occured while running'. &HTML::Entities::encode($code).''); }