[LON-CAPA-cvs] cvs: loncom /xml lontexconvert.pm lonxml.pm run.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Mon, 28 Feb 2005 22:17:09 -0000
albertel Mon Feb 28 17:17:09 2005 EDT
Modified files:
/loncom/xml lontexconvert.pm lonxml.pm run.pm
Log:
- stop allowing infinte loops to cause havoc, nesting alram() doesn't work so we need to fake the ability to do it.
Index: loncom/xml/lontexconvert.pm
diff -u loncom/xml/lontexconvert.pm:1.62 loncom/xml/lontexconvert.pm:1.63
--- loncom/xml/lontexconvert.pm:1.62 Mon Feb 28 14:08:11 2005
+++ loncom/xml/lontexconvert.pm Mon Feb 28 17:17:09 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# TeX Conversion Module
#
-# $Id: lontexconvert.pm,v 1.62 2005/02/28 19:08:11 albertel Exp $
+# $Id: lontexconvert.pm,v 1.63 2005/02/28 22:17:09 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -98,7 +98,7 @@
$Apache::lontexconvert::messedup=1;
die &mt("TeX unconverted due to errors");
};
- alarm($Apache::lonnet::perlvar{'lonScriptTimeout'});
+ &Apache::lonxml::start_alarm();
if ($ENV{'browser.mathml'}) {
$xmlstring=&tth::ttm($$texstring);
$xmlstring=~s/\<math\>/\<math xmlns=\"\&mathns\;\"\>/g;
@@ -113,7 +113,7 @@
$xmlstring=~s/^\s*\<br clear\=\"all\"/\<br/s;
$xmlstring=~s/^\s*//;
$xmlstring=~s/\s*$//;
- alarm(0);
+ &Apache::lonxml::end_alarm();
return ($xmlstring,$errorstring);
}
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.357 loncom/xml/lonxml.pm:1.358
--- loncom/xml/lonxml.pm:1.357 Sat Feb 26 00:37:23 2005
+++ loncom/xml/lonxml.pm Mon Feb 28 17:17:09 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.357 2005/02/26 05:37:23 albertel Exp $
+# $Id: lonxml.pm,v 1.358 2005/02/28 22:17:09 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -358,8 +358,8 @@
my @stack = ();
my @parstack = ();
- &initdepth;
-
+ &initdepth();
+ &init_alarm();
my $finaloutput = &inner_xmlparse($target,\@stack,\@parstack,\@pars,
$safeeval,\%style_for_target);
@@ -792,6 +792,28 @@
}
}
+{
+ my $alarm_depth;
+ sub init_alarm {
+ alarm(0);
+ $alarm_depth=0;
+ }
+
+ sub start_alarm {
+ if ($alarm_depth<1) {
+ my $old=alarm($Apache::lonnet::perlvar{'lonScriptTimeout'});
+ if ($old) {
+ &Apache::lonxml::error("Cancelled an alarm of $old, this shouldn't occur.");
+ }
+ }
+ $alarm_depth++;
+ }
+
+ sub end_alarm {
+ $alarm_depth--;
+ if ($alarm_depth<1) { alarm(0); }
+ }
+}
my $metamode_was;
sub startredirection {
if (!$Apache::lonxml::redirection) {
@@ -1267,7 +1289,8 @@
$Apache::lonxml::debug=$ENV{'user.debug'};
if ($ENV{'browser.mathml'}) {
- &Apache::loncommon::content_type($request,'text/xml');
+ #&Apache::loncommon::content_type($request,'text/xml');
+ &Apache::loncommon::content_type($request,'text/html');
} else {
&Apache::loncommon::content_type($request,'text/html');
}
Index: loncom/xml/run.pm
diff -u loncom/xml/run.pm:1.50 loncom/xml/run.pm:1.51
--- loncom/xml/run.pm:1.50 Sat Feb 26 01:10:30 2005
+++ loncom/xml/run.pm Mon Feb 28 17:17:09 2005
@@ -1,6 +1,6 @@
package Apache::run;
#
-# $Id: run.pm,v 1.50 2005/02/26 06:10:30 albertel Exp $
+# $Id: run.pm,v 1.51 2005/02/28 22:17:09 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -83,13 +83,13 @@
};
my $innererror;
eval {
- alarm($Apache::lonnet::perlvar{'lonScriptTimeout'});
+ &Apache::lonxml::start_alarm();
$safeeval->reval('{'.$decls.';$_=<<\'EXPRESSION\';'."\n".$expression.
"\n".'EXPRESSION'."\n".$EVALUATE_STRING.'}');
$innererror=$@;
- alarm(0);
+ &Apache::lonxml::end_alarm();
};
- my $error=$@;
+ my $error=$@;
if ($error eq '' && $innererror eq '' && !$Apache::run::timeout) {
$result = $safeeval->reval('return $_;');
chomp $result;
@@ -121,10 +121,10 @@
};
my $innererror;
eval {
- alarm($Apache::lonnet::perlvar{'lonScriptTimeout'});
+ &Apache::lonxml::start_alarm();
@result=$safeeval->reval($code);
$innererror=$@;
- alarm(0);
+ &Apache::lonxml::end_alarm();
};
my $error=$@;
if (($Apache::run::timeout || $error ne '' || $innererror ne '') && !$hideerrors) {