--- loncom/xml/lonxml.pm 2005/01/30 12:56:45 1.354 +++ loncom/xml/lonxml.pm 2005/02/28 22:21:40 1.359 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.354 2005/01/30 12:56:45 www Exp $ +# $Id: lonxml.pm,v 1.359 2005/02/28 22:21:40 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -149,20 +149,25 @@ $Apache::lonxml::post_evaluate=1; $Apache::lonxml::warnings_error_header=''; sub xmlbegin { - my $output=''; - @htmlareafields=(); - if ($ENV{'browser.mathml'}) { - $output='' - .'' - .']>' + my ($style)=@_; + my $output=''; + @htmlareafields=(); + if ($ENV{'browser.mathml'}) { + $output='' + #.''."\n" +# .'] >' + .'' .''; - } else { - $output=' -'; - } - return $output; + .'xmlns="http://www.w3.org/1999/xhtml">'; + } else { + $output=''; + } + if ($style eq 'encode') { + $output=&HTML::Entities::encode($output,'<>&"'); + } + return $output; } sub xmlend { @@ -284,7 +289,7 @@ sub printtokenheader { } } -sub fontsettings() { +sub fontsettings { my $headerstring=''; if (($ENV{'browser.os'} eq 'mac') && (!$ENV{'browser.mathml'})) { $headerstring.= @@ -353,8 +358,8 @@ sub xmlparse { my @stack = (); my @parstack = (); - &initdepth; - + &initdepth(); + &init_alarm(); my $finaloutput = &inner_xmlparse($target,\@stack,\@parstack,\@pars, $safeeval,\%style_for_target); @@ -384,7 +389,8 @@ sub htmlclean { # Make standard tags lowercase foreach ('html','body','head','meta','h1','h2','h3','h4','b','i','m', 'table','tr','td','th','p','br','hr','img','embed','font', - 'a','strong','center','title','basefont') { + 'a','strong','center','title','basefont','li','ol','ul', + 'input','select','form','option','script','pre') { $raw=~s/\<$_\s*\>/\<$_\>/gis; $raw=~s/\<\/$_\s*\>/<\/$_\>/gis; $raw=~s/\<$_\s([^\>]*)\>/<$_ $1\>/gis; @@ -786,6 +792,28 @@ sub default_homework_load { } } +{ + 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) {