--- loncom/xml/lonxml.pm 2001/08/07 16:54:14 1.106 +++ loncom/xml/lonxml.pm 2001/08/07 22:57:50 1.107 @@ -284,19 +284,20 @@ sub xmlparse { } sub htmlclean { - my $raw=shift; + my ($raw,$full)=@_; my $tree = HTML::TreeBuilder->new; $tree->ignore_unknown(0); $tree->parse($raw); - my %emptyhash=(); - my $output= $tree->as_HTML(undef,' ',\%emptyhash), "\n"; + my $output= $tree->as_HTML(undef,' '); $output=~s/\<(br|hr|img)([^\>\/]*)\>/\<$1$2 \/\>/gis; $output=~s/\<\/(br|hr|img)\>//gis; - $output=~s/\<[\/]*(body|head|html)\>//gis; + unless ($full) { + $output=~s/\<[\/]*(body|head|html)\>//gis; + } $tree = $tree->delete; @@ -831,7 +832,9 @@ SIMPLECONTENT

- + +
ENDFOOTER $result=~s/(\]*\>)/$1$editheader/is; @@ -862,7 +865,7 @@ sub handler { # Edit action? Save file. # unless ($ENV{'request.state'} eq 'published') { - if ($ENV{'form.savethisfile'}) { + if (($ENV{'form.savethisfile'}) || ($ENV{'form.attemptclean'})) { &storefile($file,$ENV{'form.filecont'}); } } @@ -882,6 +885,11 @@ sub handler { ENDNOTFOUND $filecontents=''; } else { + unless ($ENV{'request.state'} eq 'published') { + if ($ENV{'form.attemptclean'}) { + $filecontents=&htmlclean($filecontents,1); + } + } $result = &Apache::lonxml::xmlparse($target,$filecontents,'',%mystyle); }