Author: mrglavas
Date: Fri May 12 12:35:42 2006
New Revision: 405847

URL: http://svn.apache.org/viewcvs?rev=405847&view=rev
Log:
Fixing a bug. When printing surrogate character pairs within an attribute 
or entity value we must ensure that content() isn't called. This method 
assumes that the serializer is writing character content and will write 
a '>' character to the stream if it believes the start tag hasn't been 
closed. And it hasn't been closed yet if we're writing an attribute value.

Modified:
    xerces/java/trunk/src/org/apache/xml/serialize/BaseMarkupSerializer.java
    xerces/java/trunk/src/org/apache/xml/serialize/XML11Serializer.java
    xerces/java/trunk/src/org/apache/xml/serialize/XMLSerializer.java

Modified: 
xerces/java/trunk/src/org/apache/xml/serialize/BaseMarkupSerializer.java
URL: 
http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xml/serialize/BaseMarkupSerializer.java?rev=405847&r1=405846&r2=405847&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xml/serialize/BaseMarkupSerializer.java 
(original)
+++ xerces/java/trunk/src/org/apache/xml/serialize/BaseMarkupSerializer.java 
Fri May 12 12:35:42 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2002,2004,2005 The Apache Software Foundation.
+ * Copyright 1999-2002,2004-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 
-
 // Sep 14, 2000:
 //  Fixed comments to preserve whitespaces and add a line break
 //  when indenting. Reported by Gervase Markham <[EMAIL PROTECTED]>
@@ -39,10 +38,8 @@
 //   entering element state.
 //   Reported by Lowell Vaughn <[EMAIL PROTECTED]>
 
-
 package org.apache.xml.serialize;
 
-
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.Writer;
@@ -508,7 +505,7 @@
                 if (!XMLChar.isValid(ch)) {
                     // check if it is surrogate
                     if (++index < end) {
-                        surrogates(ch, chars[index]);
+                        surrogates(ch, chars[index], true);
                     } 
                     else {
                         fatalError("The character '"+(char)ch+"' is an invalid 
XML character"); 
@@ -1455,7 +1452,7 @@
             if (!XMLChar.isValid(ch)) {
                 // check if it is surrogate
                 if (++index <length) {
-                    surrogates(ch, text.charAt(index));
+                    surrogates(ch, text.charAt(index), true);
                 } 
                 else {
                     fatalError("The character '"+(char)ch+"' is an invalid XML 
character"); 
@@ -1477,7 +1474,7 @@
     }
 
 
-    protected void surrogates(int high, int low) throws IOException{
+    protected void surrogates(int high, int low, boolean inContent) throws 
IOException{
         if (XMLChar.isHighSurrogate(high)) {
             if (!XMLChar.isLowSurrogate(low)) {
                 //Invalid XML
@@ -1490,7 +1487,7 @@
                     fatalError("The character '"+(char)supplemental+"' is an 
invalid XML character"); 
                 }
                 else {
-                    if (content().inCData ) {
+                    if (inContent && content().inCData) {
                         _printer.printText("]]>&#x");                        
                         _printer.printText(Integer.toHexString(supplemental)); 
                       
                         _printer.printText(";<![CDATA[");

Modified: xerces/java/trunk/src/org/apache/xml/serialize/XML11Serializer.java
URL: 
http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xml/serialize/XML11Serializer.java?rev=405847&r1=405846&r2=405847&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xml/serialize/XML11Serializer.java 
(original)
+++ xerces/java/trunk/src/org/apache/xml/serialize/XML11Serializer.java Fri May 
12 12:35:42 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2002,2004,2005 The Apache Software Foundation.
+ * Copyright 1999-2002,2004-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,8 +14,6 @@
  * limitations under the License.
  */
 
-
-
 // Sep 14, 2000:
 //  Fixed problem with namespace handling. Contributed by
 //  David Blondeau <[EMAIL PROTECTED]>
@@ -29,10 +27,8 @@
 // Aug 21, 2000:
 //  Added ability to omit DOCTYPE declaration.
 
-
 package org.apache.xml.serialize;
 
-
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.Writer;
@@ -214,7 +210,7 @@
                     if (!XML11Char.isXML11Valid(ch)) {
                         // check if it is surrogate
                         if (++index < end) {
-                            surrogates(ch, chars[index]);
+                            surrogates(ch, chars[index], true);
                         } 
                         else {
                             fatalError("The character '"+(char)ch+"' is an 
invalid XML character"); 
@@ -265,7 +261,7 @@
             int ch = source.charAt(i);
             if (!XML11Char.isXML11Valid(ch)) {
                 if (++i <length) {
-                    surrogates(ch, source.charAt(i));
+                    surrogates(ch, source.charAt(i), false);
                 } else {
                     fatalError("The character '"+(char)ch+"' is an invalid XML 
character"); 
                 }
@@ -341,7 +337,7 @@
             if (!XML11Char.isXML11Valid(ch)) {
                 // check if it is surrogate
                 if (++index < length) {
-                    surrogates(ch, text.charAt(index));
+                    surrogates(ch, text.charAt(index), true);
                 } else {
                     fatalError(
                         "The character '"
@@ -388,7 +384,7 @@
 
 
 
-    protected final void surrogates(int high, int low) throws IOException{
+    protected final void surrogates(int high, int low, boolean inContent) 
throws IOException{
         if (XMLChar.isHighSurrogate(high)) {
             if (!XMLChar.isLowSurrogate(low)) {
                 //Invalid XML
@@ -401,7 +397,7 @@
                     fatalError("The character '"+(char)supplemental+"' is an 
invalid XML character"); 
                 }
                 else {
-                    if (content().inCData ) {
+                    if (inContent && content().inCData) {
                         _printer.printText("]]>&#x");                        
                         _printer.printText(Integer.toHexString(supplemental)); 
                       
                         _printer.printText(";<![CDATA[");
@@ -433,7 +429,7 @@
                 if (!XML11Char.isXML11Valid(ch)) {
                     // check if it is surrogate
                     if (++index <length) {
-                        surrogates(ch, text.charAt(index));
+                        surrogates(ch, text.charAt(index), true);
                     } else {
                         fatalError("The character '"+(char)ch+"' is an invalid 
XML character"); 
                     }
@@ -455,7 +451,7 @@
                 if (!XML11Char.isXML11Valid(ch)) {
                     // check if it is surrogate
                     if (++index <length) {
-                        surrogates(ch, text.charAt(index));
+                        surrogates(ch, text.charAt(index), true);
                     } else {
                         fatalError("The character '"+(char)ch+"' is an invalid 
XML character"); 
                     }
@@ -487,7 +483,7 @@
                 if (!XML11Char.isXML11Valid(ch)) {
                     // check if it is surrogate
                     if ( length-- > 0) {
-                        surrogates(ch, chars[start++]);
+                        surrogates(ch, chars[start++], true);
                     } else {
                         fatalError("The character '"+(char)ch+"' is an invalid 
XML character"); 
                     }
@@ -509,7 +505,7 @@
                 if (!XML11Char.isXML11Valid(ch)) {
                     // check if it is surrogate
                     if ( length-- > 0) {
-                        surrogates(ch, chars[start++]);
+                        surrogates(ch, chars[start++], true);
                     } else {
                         fatalError("The character '"+(char)ch+"' is an invalid 
XML character"); 
                     }

Modified: xerces/java/trunk/src/org/apache/xml/serialize/XMLSerializer.java
URL: 
http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xml/serialize/XMLSerializer.java?rev=405847&r1=405846&r2=405847&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xml/serialize/XMLSerializer.java (original)
+++ xerces/java/trunk/src/org/apache/xml/serialize/XMLSerializer.java Fri May 
12 12:35:42 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2002,2004,2005 The Apache Software Foundation.
+ * Copyright 1999-2002,2004-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,8 +14,6 @@
  * limitations under the License.
  */
 
-
-
 // Sep 14, 2000:
 //  Fixed problem with namespace handling. Contributed by
 //  David Blondeau <[EMAIL PROTECTED]>
@@ -29,10 +27,8 @@
 // Aug 21, 2000:
 //  Added ability to omit DOCTYPE declaration.
 
-
 package org.apache.xml.serialize;
 
-
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.Writer;
@@ -1230,7 +1226,7 @@
             int ch = source.charAt(i);
             if (!XMLChar.isValid(ch)) {
                 if (++i < length) {
-                    surrogates(ch, source.charAt(i));
+                    surrogates(ch, source.charAt(i), false);
                 } else {
                     fatalError("The character '" + (char) ch + "' is an 
invalid XML character");
                 }
@@ -1288,7 +1284,7 @@
                 if (!XMLChar.isValid(ch)) {
                     // check if it is surrogate
                     if (++index <length) {
-                        surrogates(ch, text.charAt(index));
+                        surrogates(ch, text.charAt(index), true);
                     } else {
                         fatalError("The character '"+(char)ch+"' is an invalid 
XML character"); 
                     }
@@ -1310,7 +1306,7 @@
                 if (!XMLChar.isValid(ch)) {
                     // check if it is surrogate
                     if (++index <length) {
-                        surrogates(ch, text.charAt(index));
+                        surrogates(ch, text.charAt(index), true);
                     } else {
                         fatalError("The character '"+(char)ch+"' is an invalid 
XML character"); 
                     }
@@ -1342,7 +1338,7 @@
                 if (!XMLChar.isValid(ch)) {
                     // check if it is surrogate
                     if ( length-- > 0 ) {
-                        surrogates(ch, chars[start++]);
+                        surrogates(ch, chars[start++], true);
                     } else {
                         fatalError("The character '"+(char)ch+"' is an invalid 
XML character"); 
                     }
@@ -1364,7 +1360,7 @@
                 if (!XMLChar.isValid(ch)) {
                     // check if it is surrogate
                     if ( length-- > 0 ) {
-                        surrogates(ch, chars[start++]);
+                        surrogates(ch, chars[start++], true);
                     } else {
                         fatalError("The character '"+(char)ch+"' is an invalid 
XML character"); 
                     }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to