[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm /publisher lonpublisher.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Wed, 10 Apr 2002 15:28:45 -0000
albertel Wed Apr 10 11:28:45 2002 EDT
Modified files:
/loncom/lonnet/perl lonnet.pm
/loncom/publisher lonpublisher.pm
Log:
- address BUG#68 and BUG#153, also helps out with BUG#179
- metadata is now stored with Entities escaped, making it easy and possible to put HTML in metadata
- publication protects Entities beofre dumping them into the edit windos this should fix any issues with publishing Entities in metadata.
- attributes stay encoded during publication
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.207 loncom/lonnet/perl/lonnet.pm:1.208
--- loncom/lonnet/perl/lonnet.pm:1.207 Thu Apr 4 15:37:05 2002
+++ loncom/lonnet/perl/lonnet.pm Wed Apr 10 11:28:45 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.207 2002/04/04 20:37:05 albertel Exp $
+# $Id: lonnet.pm,v 1.208 2002/04/10 15:28:45 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -84,7 +84,7 @@
use IO::Socket;
use GDBM_File;
use Apache::Constants qw(:common :http);
-use HTML::TokeParser;
+use HTML::LCParser;
use Fcntl qw(:flock);
my $readit;
@@ -2389,7 +2389,7 @@
my %metathesekeys=();
unless ($filename=~/\.meta$/) { $filename.='.meta'; }
my $metastring=&getfile($perlvar{'lonDocRoot'}.'/res/'.$filename);
- my $parser=HTML::TokeParser->new(\$metastring);
+ my $parser=HTML::LCParser->new(\$metastring);
my $token;
undef %metathesekeys;
while ($token=$parser->get_token) {
@@ -2478,7 +2478,7 @@
$metacache{$uri.':'.$unikey.'.'.$_}=$token->[2]->{$_};
}
unless (
- $metacache{$uri.':'.$unikey}=$parser->get_text('/'.$entry)
+ $metacache{$uri.':'.$unikey}=&HTML::Entities::decode($parser->get_text('/'.$entry))
) { $metacache{$uri.':'.$unikey}=
$metacache{$uri.':'.$unikey.'.default'};
}
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.75 loncom/publisher/lonpublisher.pm:1.76
--- loncom/publisher/lonpublisher.pm:1.75 Mon Mar 25 12:09:21 2002
+++ loncom/publisher/lonpublisher.pm Wed Apr 10 11:28:45 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Publication Handler
#
-# $Id: lonpublisher.pm,v 1.75 2002/03/25 17:09:21 matthew Exp $
+# $Id: lonpublisher.pm,v 1.76 2002/04/10 15:28:45 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -68,7 +68,7 @@
use Apache::File;
use File::Copy;
use Apache::Constants qw(:common :http :methods);
-use HTML::TokeParser;
+use HTML::LCParser;
use Apache::lonxml;
use Apache::lonhomework;
use Apache::loncacc;
@@ -91,7 +91,7 @@
sub metaeval {
my $metastring=shift;
- my $parser=HTML::TokeParser->new(\$metastring);
+ my $parser=HTML::LCParser->new(\$metastring);
my $token;
while ($token=$parser->get_token) {
if ($token->[0] eq 'S') {
@@ -257,7 +257,7 @@
$content=join('',<$org>);
}
{
- my $parser=HTML::TokeParser->new(\$content);
+ my $parser=HTML::LCParser->new(\$content);
my $token;
while ($token=$parser->get_token) {
if ($token->[0] eq 'S') {
@@ -288,7 +288,7 @@
"Max Index: $maxindex (min 10)\n";
}
my $outstring='';
- my $parser=HTML::TokeParser->new(\$content);
+ my $parser=HTML::LCParser->new(\$content);
$parser->xml_mode(1);
my $token;
while ($token=$parser->get_token) {
@@ -429,6 +429,8 @@
$allowstr=~s/\n+/\n/g;
$outstring=~s/(\<\/[^\>]+\>\s*)$/$allowstr$1/s;
+ #Encode any High ASCII characters
+ $outstring=&HTML::Entities::encode($outstring,"\200-\377");
# ------------------------------------------------------------- Write modified
{
@@ -722,7 +724,9 @@
$value=~s/\"/\'\'/g;
print $mfh ' '.$_.'="'.$value.'"';
}
- print $mfh '>'.$metadatafields{$unikey}.'</'.$tag.'>';
+ print $mfh '>'.
+ &HTML::Entities::encode($metadatafields{$unikey})
+ .'</'.$tag.'>';
}
}
$scrout.='<p>Wrote Metadata';