mrglavas    2005/04/17 21:54:06

  Modified:    java/src/org/apache/xml/serialize XML11Serializer.java
                        XMLSerializer.java
  Log:
  Fixing JIRA Issue #1063:
  http://issues.apache.org/jira/browse/XERCESJ-1063
  
  When start >= length a fatal error was emitted for surrogate characters.
  Since length is decremented on each loop and since start is an offset which
  doesn't necessarily start from zero this comparison isn't valid. Should be
  fixed now.
  
  Revision  Changes    Path
  1.11      +7 -10     
xml-xerces/java/src/org/apache/xml/serialize/XML11Serializer.java
  
  Index: XML11Serializer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xml/serialize/XML11Serializer.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- XML11Serializer.java      14 May 2004 19:37:53 -0000      1.10
  +++ XML11Serializer.java      18 Apr 2005 04:54:06 -0000      1.11
  @@ -482,12 +482,11 @@
               // consolidating spaces. If a line terminator is used, a line
               // break will occur.
               while ( length-- > 0 ) {
  -                ch = chars[ start ];
  -                ++start;
  +                ch = chars[start++];
                   if (!XML11Char.isXML11Valid(ch)) {
                       // check if it is surrogate
  -                    if (++start <length) {
  -                        surrogates(ch, chars[start]);
  +                    if ( length-- > 0) {
  +                        surrogates(ch, chars[start++]);
                       } else {
                           fatalError("The character '"+(char)ch+"' is an 
invalid XML character"); 
                       }
  @@ -505,13 +504,11 @@
               // by printing mechanism. Line terminator is treated
               // no different than other text part.
               while ( length-- > 0 ) {
  -                ch = chars[ start ];
  -                ++start;
  -
  +                ch = chars[start++];
                   if (!XML11Char.isXML11Valid(ch)) {
                       // check if it is surrogate
  -                    if (++start <length) {
  -                        surrogates(ch, chars[start]);
  +                    if ( length-- > 0) {
  +                        surrogates(ch, chars[start++]);
                       } else {
                           fatalError("The character '"+(char)ch+"' is an 
invalid XML character"); 
                       }
  
  
  
  1.65      +7 -10     
xml-xerces/java/src/org/apache/xml/serialize/XMLSerializer.java
  
  Index: XMLSerializer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xml/serialize/XMLSerializer.java,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- XMLSerializer.java        10 Feb 2005 19:37:21 -0000      1.64
  +++ XMLSerializer.java        18 Apr 2005 04:54:06 -0000      1.65
  @@ -1338,12 +1338,11 @@
               // consolidating spaces. If a line terminator is used, a line
               // break will occur.
               while ( length-- > 0 ) {
  -                ch = chars[ start ];
  -                ++start;
  +                ch = chars[start++];
                   if (!XMLChar.isValid(ch)) {
                       // check if it is surrogate
  -                    if (++start <length) {
  -                        surrogates(ch, chars[start]);
  +                    if ( length-- > 0 ) {
  +                        surrogates(ch, chars[start++]);
                       } else {
                           fatalError("The character '"+(char)ch+"' is an 
invalid XML character"); 
                       }
  @@ -1361,13 +1360,11 @@
               // by printing mechanism. Line terminator is treated
               // no different than other text part.
               while ( length-- > 0 ) {
  -                ch = chars[ start ];
  -                ++start;
  -
  +                ch = chars[start++];
                   if (!XMLChar.isValid(ch)) {
                       // check if it is surrogate
  -                    if (++start <length) {
  -                        surrogates(ch, chars[start]);
  +                    if ( length-- > 0 ) {
  +                        surrogates(ch, chars[start++]);
                       } 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