[LON-CAPA-cvs] cvs: loncom /xml lonxml.pm scripttag.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Mon, 13 Jan 2003 22:18:34 -0000
albertel Mon Jan 13 17:18:34 2003 EDT
Modified files:
/loncom/xml scripttag.pm lonxml.pm
Log:
- if you can't find the end tag when doing get_all_text throw an
error and send nothing back, (No need to send random garbage into the
perl interpreter)
- have <script> and <display> send the full parser stack
Index: loncom/xml/scripttag.pm
diff -u loncom/xml/scripttag.pm:1.83 loncom/xml/scripttag.pm:1.84
--- loncom/xml/scripttag.pm:1.83 Thu Nov 14 11:47:41 2002
+++ loncom/xml/scripttag.pm Mon Jan 13 17:18:34 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# <script> definiton
#
-# $Id: scripttag.pm,v 1.83 2002/11/14 16:47:41 matthew Exp $
+# $Id: scripttag.pm,v 1.84 2003/01/13 22:18:34 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -63,7 +63,7 @@
my $type= &Apache::lonxml::get_param('type',$parstack,$safeeval);
&Apache::lonxml::debug("found type of $type");
if ($type eq "loncapa/perl") {
- my $bodytext=&Apache::lonxml::get_all_text("/script",$$parser[$#$parser]);
+ my $bodytext=&Apache::lonxml::get_all_text("/script",$parser);
if ( $target eq "modified" ) {
$result=$token->[4].&Apache::edit::modifiedfield();
} elsif ( $target eq 'web' || $target eq 'tex' ||
@@ -117,7 +117,7 @@
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
my $result;
- my $bodytext=&Apache::lonxml::get_all_text("/display",$$parser[$#$parser]);
+ my $bodytext=&Apache::lonxml::get_all_text("/display",$parser);
if ( $target eq "modified" ) {
$result=$token->[4].&Apache::edit::modifiedfield();
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.223 loncom/xml/lonxml.pm:1.224
--- loncom/xml/lonxml.pm:1.223 Tue Jan 7 12:02:10 2003
+++ loncom/xml/lonxml.pm Mon Jan 13 17:18:34 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.223 2003/01/07 17:02:10 albertel Exp $
+# $Id: lonxml.pm,v 1.224 2003/01/13 22:18:34 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -774,7 +774,7 @@
if ($token->[0] eq 'E') {
&end_tag($stack,$parstack,$token);
}
- }
+ }
if ($#$pars > -1) {
pop @$pars;
pop @Apache::lonxml::pwd;
@@ -1116,7 +1116,9 @@
sub get_all_text {
my($tag,$pars)= @_;
&Apache::lonxml::debug("Got a ".ref($pars));
+ my $gotfullstack=1;
if (ref($pars) ne 'ARRAY') {
+ $gotfullstack=0;
$pars=[$pars];
}
my $depth=0;
@@ -1148,7 +1150,16 @@
pop(@$pars);
pop(@Apache::lonxml::pwd);
}
- if (($depth >=0) && ($#$pars == 0) ) { $top_empty=1; }
+ if (($depth >=0) && ($#$pars == 0) ) { &debug("here4");$top_empty=1; }
+ }
+ if ($top_empty && $depth >= 0) {
+ #never found the end tag ran out of text, throw error send back blank
+ &error('Never found end tag for <'.$tag.'>');
+ if ($gotfullstack) {
+ my $newstring='</'.$tag.'>'.$result;
+ &Apache::lonxml::newparser($pars,\$newstring);
+ }
+ $result='';
}
} else {
while ($#$pars > -1) {