mrglavas    2005/04/17 22:16:08

  Modified:    java/src/org/apache/xml/serialize XML11Serializer.java
                        BaseMarkupSerializer.java
  Log:
  Fixing a bug. In the loop handling a CDATA section we should be
  comparing the current position against the end offset, not the length.
  
  Revision  Changes    Path
  1.13      +5 -4      
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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- XML11Serializer.java      18 Apr 2005 04:55:51 -0000      1.12
  +++ XML11Serializer.java      18 Apr 2005 05:16:08 -0000      1.13
  @@ -202,9 +202,10 @@
                   saveIndent = _printer.getNextIndent();
                   _printer.setNextIndent( 0 );
                   char ch;
  -                for ( int index = start ; index < length ; ++index ) {
  +                final int end = start + length;
  +                for ( int index = start; index < end; ++index ) {
                       ch = chars[index];
  -                    if ( ch == ']' && index + 2 < length &&
  +                    if ( ch == ']' && index + 2 < end &&
                           chars[ index + 1 ] == ']' && chars[ index + 2 ] == 
'>' ) {
                           _printer.printText("]]]]><![CDATA[>");
                           index +=2; 
  @@ -212,7 +213,7 @@
                       }
                       if (!XML11Char.isXML11Valid(ch)) {
                           // check if it is surrogate
  -                        if (++index <length) {
  +                        if (++index < end) {
                               surrogates(ch, chars[index]);
                           } 
                           else {
  
  
  
  1.56      +6 -5      
xml-xerces/java/src/org/apache/xml/serialize/BaseMarkupSerializer.java
  
  Index: BaseMarkupSerializer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xml/serialize/BaseMarkupSerializer.java,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- BaseMarkupSerializer.java 23 Jun 2004 03:41:05 -0000      1.55
  +++ BaseMarkupSerializer.java 18 Apr 2005 05:16:08 -0000      1.56
  @@ -1,5 +1,5 @@
   /*
  - * Copyright 1999-2002,2004 The Apache Software Foundation.
  + * Copyright 1999-2002,2004,2005 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.
  @@ -496,9 +496,10 @@
               saveIndent = _printer.getNextIndent();
               _printer.setNextIndent( 0 );
               char ch;
  -            for ( int index = start ; index < length ; ++index ) {
  +            final int end = start + length;
  +            for ( int index = start ; index < end; ++index ) {
                   ch = chars[index];
  -                if ( ch == ']' && index + 2 < length &&
  +                if ( ch == ']' && index + 2 < end &&
                        chars[ index + 1 ] == ']' && chars[ index + 2 ] == '>' 
) {
                       _printer.printText("]]]]><![CDATA[>");
                       index +=2; 
  @@ -506,7 +507,7 @@
                   }
                   if (!XMLChar.isValid(ch)) {
                       // check if it is surrogate
  -                    if (++index <length) {
  +                    if (++index < end) {
                           surrogates(ch, chars[index]);
                       } 
                       else {
  
  
  

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

Reply via email to