--- loncom/xml/lonxml.pm 2002/05/01 21:40:25 1.168 +++ loncom/xml/lonxml.pm 2002/05/16 00:56:46 1.169 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.168 2002/05/01 21:40:25 albertel Exp $ +# $Id: lonxml.pm,v 1.169 2002/05/16 00:56:46 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -60,7 +60,7 @@ package Apache::lonxml; use vars -qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace); +qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace $prevent_entity_encode); use strict; use HTML::LCParser(); use HTML::TreeBuilder(); @@ -129,6 +129,9 @@ $evaluate = 1; # stores the list of active tag namespaces @namespace=(); +# if 0 all high ASCII characters will be encoded into HTML Entities +$prevent_entity_encode=0; + # has the dynamic menu been updated to know about this resource $Apache::lonxml::registered=0; @@ -624,18 +627,22 @@ sub inner_xmlparse { #evaluate variable refs in result if ($result ne "") { if ( $#$parstack > -1 ) { - if ($Apache::lonxml::redirection) { - $Apache::lonxml::outputstack['-1'] .= - &Apache::run::evaluate($result,$safeeval,$$parstack['-1']); - } else { - $finaloutput .= &Apache::run::evaluate($result,$safeeval, - $$parstack['-1']); - } + $result=&Apache::run::evaluate($result,$safeeval,$$parstack[-1]); } else { - $finaloutput .= &Apache::run::evaluate($result,$safeeval,''); + $result= &Apache::run::evaluate($result,$safeeval,''); } - $result = ''; } + # Encode any high ASCII characters + if (!$Apache::lonxml::prevent_entity_encode) { + $result=&HTML::Entities::encode($result,"\200-\377"); + } + if ($Apache::lonxml::redirection) { + $Apache::lonxml::outputstack['-1'] .= $result; + } else { + $finaloutput.=$result; + } + $result = ''; + if ($token->[0] eq 'E') { &end_tag($stack,$parstack,$token); } @@ -648,8 +655,7 @@ sub inner_xmlparse { # $finaloutput.=&endredirection; # } - # Encode any high ASCII characters - $finaloutput=&HTML::Entities::encode($finaloutput,"\200-\377"); + if (($ENV{'QUERY_STRING'}) && ($target eq 'web')) { $finaloutput=&afterburn($finaloutput); }