[LON-CAPA-cvs] cvs: loncom /homework/cleanxml xml_to_loncapa.pm
damieng
damieng at source.lon-capa.org
Fri Dec 18 17:08:52 EST 2015
damieng Fri Dec 18 22:08:52 2015 EDT
Modified files:
/loncom/homework/cleanxml xml_to_loncapa.pm
Log:
attribute values are not escaped (except for quotes) in LON-CAPA syntax
Index: loncom/homework/cleanxml/xml_to_loncapa.pm
diff -u loncom/homework/cleanxml/xml_to_loncapa.pm:1.1 loncom/homework/cleanxml/xml_to_loncapa.pm:1.2
--- loncom/homework/cleanxml/xml_to_loncapa.pm:1.1 Thu Dec 3 20:40:31 2015
+++ loncom/homework/cleanxml/xml_to_loncapa.pm Fri Dec 18 22:08:51 2015
@@ -1,7 +1,7 @@
# The LearningOnline Network
# convert_file takes a well-formed XML file content and converts it to LON-CAPA syntax.
#
-# $Id: xml_to_loncapa.pm,v 1.1 2015/12/03 20:40:31 damieng Exp $
+# $Id: xml_to_loncapa.pm,v 1.2 2015/12/18 22:08:51 damieng Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -92,7 +92,7 @@
$s .= ' ';
$s .= $attribute->nodeName;
$s .= '="';
- $s .= escape($attribute->nodeValue);
+ $s .= escape_attribute($attribute->nodeValue);
$s .= '"';
}
if ($node->hasChildNodes()) {
@@ -110,13 +110,14 @@
}
}
-# Escapes a string for LON-CAPA output (used for text nodes, not attribute values)
-sub escape {
+# Escapes an attribute value
+sub escape_attribute {
my ($s) = @_;
- $s =~ s/&/&/sg;
- $s =~ s/</</sg;
- $s =~ s/>/>/sg;
- # quot and apos do not need to be escaped outside attribute values
+ # normal XML escapes do not work with LON-CAPA, for instance with reactionresponse
+ #$s =~ s/&/&/sg;
+ #$s =~ s/</</sg;
+ #$s =~ s/>/>/sg;
+ $s =~ s/"/"/sg;
return $s;
}
More information about the LON-CAPA-cvs
mailing list