changeset 294:8ab68d19c6f7

PR766 javaws fails to parse an <argument> node that contains CDATA 2011-09-21 Omair Majid <omajid@redhat.com> PR766: javaws fails to parse an <argument> node that contains CDATA * netx/net/sourceforge/nanoxml/XMLElement.java (sanitizeInput): Do not remove CDATA sections along with comments.
author Omair Majid <omajid@redhat.com>
date Wed, 21 Sep 2011 14:45:25 -0400
parents 739a31d80baf
children 1fc5f8ceb75c
files ChangeLog netx/net/sourceforge/nanoxml/XMLElement.java
diffstat 2 files changed, 35 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Sep 21 14:36:44 2011 -0400
+++ b/ChangeLog	Wed Sep 21 14:45:25 2011 -0400
@@ -1,3 +1,9 @@
+2011-09-21  Omair Majid  <omajid@redhat.com>
+
+	PR766: javaws fails to parse an <argument> node that contains CDATA
+	* netx/net/sourceforge/nanoxml/XMLElement.java
+	(sanitizeInput): Do not remove CDATA sections along with comments.
+
 2011-09-20  Omair Majid  <omajid@redhat.com>
 
 	* tests/netx/unit/net/sourceforge/jnlp/ParserCornerCases.java
--- a/netx/net/sourceforge/nanoxml/XMLElement.java	Wed Sep 21 14:36:44 2011 -0400
+++ b/netx/net/sourceforge/nanoxml/XMLElement.java	Wed Sep 21 14:45:25 2011 -0400
@@ -1166,7 +1166,7 @@
      * @param pout The PipedOutputStream that will be receiving the filtered
      *             xml file.
      */
-    public void sanitizeInput(InputStreamReader isr, PipedOutputStream pout) {
+    public void sanitizeInput(Reader isr, OutputStream pout) {
         try {
             PrintStream out = new PrintStream(pout);
 
@@ -1220,11 +1220,35 @@
 
                 this.sanitizeCharReadTooMuch = next;
 
-                // If the next char is a ? or !, then we've hit a special tag,
+                // If the next chars are !--, then we've hit a comment tag,
                 // and should skip it.
-                if (prev == '<' && (next == '!' || next == '?')) {
-                    this.skipSpecialTag(0);
-                    this.sanitizeCharReadTooMuch = '\0';
+                if (ch == '<' && sanitizeCharReadTooMuch == '!') {
+                    ch = (char) this.reader.read();
+                    if (ch == '-') {
+                        ch = (char) this.reader.read();
+                        if (ch == '-') {
+                            this.skipComment();
+                            this.sanitizeCharReadTooMuch = '\0';
+                        } else {
+                            out.print('<');
+                            out.print('!');
+                            out.print('-');
+                            this.sanitizeCharReadTooMuch = ch;
+                            if (JNLPRuntime.isDebug()) {
+                                System.out.print('<');
+                                System.out.print('!');
+                                System.out.print('-');
+                            }
+                        }
+                    } else {
+                        out.print('<');
+                        out.print('!');
+                        this.sanitizeCharReadTooMuch = ch;
+                        if (JNLPRuntime.isDebug()) {
+                            System.out.print('<');
+                            System.out.print('!');
+                        }
+                    }
                 }
                 // Otherwise we haven't hit a comment, and we should write ch.
                 else {