Permalink
Browse files

applied second patch from David Madore to be less intrusive when hand…

…ling

* xmlsave.c: applied second patch from David Madore to be less intrusive
  when handling scripts and style elements in XHTML1 should fix #316041
* test/xhtml1 result//xhtml1\*: updated the test accordingly
Daniel
  • Loading branch information...
Daniel Veillard
Daniel Veillard committed Sep 12, 2005
1 parent 1db4a66 commit dbd61053214d07e7cd9ffc75152fabbe6ae9ddff
Showing with 33 additions and 18 deletions.
  1. +6 −0 ChangeLog
  2. +1 −1 result/noent/xhtml1
  3. +1 −1 result/xhtml1
  4. +1 −1 result/xhtml1.rde
  5. +1 −1 result/xhtml1.rdr
  6. +5 −1 result/xhtml1.sax
  7. +5 −1 result/xhtml1.sax2
  8. +1 −1 test/xhtml1
  9. +12 −11 xmlsave.c
View
@@ -1,3 +1,9 @@
+Mon Sep 12 16:02:12 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+ * xmlsave.c: applied second patch from David Madore to be less intrusive
+ when handling scripts and style elements in XHTML1 should fix #316041
+ * test/xhtml1 result//xhtml1\*: updated the test accordingly
+
Mon Sep 12 15:09:09 CEST 2005 Daniel Veillard <daniel@veillard.com>
* libxml.spec.in doc/devhelp/*: finished the integration with
View
@@ -7,7 +7,7 @@
</head>
<!-- 4.8 -->
<script type="text/javascript"><![CDATA[
- ... unescaped script content ...
+ ... unescaped script < content ...
]]></script>
<body>
<p>Moved to <a href="http://example.org/">example.org</a>.</p>
View
@@ -7,7 +7,7 @@
</head>
<!-- 4.8 -->
<script type="text/javascript"><![CDATA[
- ... unescaped script content ...
+ ... unescaped script < content ...
]]></script>
<body>
<p>Moved to <a href="http://example.org/">example.org</a>.</p>
View
@@ -19,7 +19,7 @@
1 1 script 0 0
2 3 #text 0 1
- ... unescaped script content ...
+ ... unescaped script < content ...
1 15 script 0 0
1 14 #text 0 1
View
@@ -19,7 +19,7 @@
1 1 script 0 0
2 3 #text 0 1
- ... unescaped script content ...
+ ... unescaped script < content ...
1 15 script 0 0
1 14 #text 0 1
View
@@ -22,7 +22,11 @@ SAX.characters(
, 3)
SAX.startElement(script, type='text/javascript')
SAX.characters(
- ... unescaped script conten, 38)
+ ... unescaped script , 24)
+SAX.getEntity(lt)
+SAX.characters(<, 1)
+SAX.characters( content ...
+ , 15)
SAX.endElement(script)
SAX.characters(
, 3)
View
@@ -22,7 +22,11 @@ SAX.characters(
, 3)
SAX.startElementNs(script, NULL, NULL, 0, 1, 0, type='text...', 15)
SAX.characters(
- ... unescaped script conten, 38)
+ ... unescaped script , 24)
+SAX.getEntity(lt)
+SAX.characters(<, 1)
+SAX.characters( content ...
+ , 15)
SAX.endElementNs(script, NULL, NULL)
SAX.characters(
, 3)
View
@@ -9,7 +9,7 @@
</head>
<!-- 4.8 -->
<script type="text/javascript">
- ... unescaped script content ...
+ ... unescaped script &lt; content ...
</script>
<body>
<p>Moved to <a href="http://example.org/">example.org</a>.</p>
View
@@ -1321,25 +1321,26 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
xmlNodePtr child = cur->children;
while (child != NULL) {
- if ((child->type == XML_TEXT_NODE) ||
- (child->type == XML_CDATA_SECTION_NODE)) {
- /*
- * Apparently CDATA escaping for style just break on IE,
- * mozilla and galeon, so ...
- */
- if (xmlStrEqual(cur->name, BAD_CAST "style") &&
- (xmlStrchr(child->content, '<') == NULL) &&
- (xmlStrchr(child->content, '>') == NULL) &&
- (xmlStrchr(child->content, '&') == NULL)) {
+ if (child->type == XML_TEXT_NODE) {
+ if ((xmlStrchr(child->content, '<') == NULL) &&
+ (xmlStrchr(child->content, '&') == NULL) &&
+ (xmlStrstr(child->content, BAD_CAST "]]>") == NULL)) {
+ /* Nothing to escape, so just output as is... */
+ /* FIXME: Should we do something about "--" also? */
int level = ctxt->level;
int indent = ctxt->format;
ctxt->level = 0;
ctxt->format = 0;
- xhtmlNodeDumpOutput(ctxt, child);
+ xmlOutputBufferWriteString(buf, (const char *) child->content);
+ /* (We cannot use xhtmlNodeDumpOutput() here because
+ * we wish to leave '>' unescaped!) */
ctxt->level = level;
ctxt->format = indent;
} else {
+ /* We must use a CDATA section. Unfortunately,
+ * this will break CSS and JavaScript when read by
+ * a browser in HTML4-compliant mode. :-( */
start = end = child->content;
while (*end != '\0') {
if (*end == ']' &&

0 comments on commit dbd6105

Please sign in to comment.