You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by an...@apache.org on 2001/10/23 10:01:52 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/impl XMLEntityManager.java XMLScanner.java

andyc       01/10/23 01:01:52

  Modified:    java/src/org/apache/xerces/impl XMLEntityManager.java
                        XMLScanner.java
  Log:
  Fixed more newline normalization bugs. This time the problem was in
  attribute values. The code to scan literals was also simplified a
  little bit.
  
  Reported by:	Aleksander Slominski <as...@cs.indiana.edu>
  
  Revision  Changes    Path
  1.10      +3 -3      xml-xerces/java/src/org/apache/xerces/impl/XMLEntityManager.java
  
  Index: XMLEntityManager.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLEntityManager.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XMLEntityManager.java	2001/10/22 16:53:47	1.9
  +++ XMLEntityManager.java	2001/10/23 08:01:51	1.10
  @@ -114,7 +114,7 @@
    * @author Andy Clark, IBM
    * @author Arnaud  Le Hors, IBM
    *
  - * @version $Id: XMLEntityManager.java,v 1.9 2001/10/22 16:53:47 sandygao Exp $
  + * @version $Id: XMLEntityManager.java,v 1.10 2001/10/23 08:01:51 andyc Exp $
    */
   public class XMLEntityManager
       implements XMLComponent, XMLEntityResolver {
  @@ -1852,19 +1852,19 @@
                       load(1, false);
                   }
                   if (c == '\r' && external) {
  -                    // REVISIT: Does this need to be updated to fix the
  -                    //          #x0D ^#x0A newline normalization problem? -Ac
                       if (fCurrentEntity.ch[fCurrentEntity.position++] != '\n') {
                           fCurrentEntity.position--;
                       }
                       c = '\n';
                   }
  +                /*** NEWLINE NORMALIZATION ***
                   else {
                       if (fCurrentEntity.ch[fCurrentEntity.position] == '\r'
                           && fCurrentEntity.isExternal()) {
                           fCurrentEntity.position++;
                       }
                   }
  +                /***/
               }
   
               // return character that was scanned
  
  
  
  1.7       +13 -48    xml-xerces/java/src/org/apache/xerces/impl/XMLScanner.java
  
  Index: XMLScanner.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLScanner.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XMLScanner.java	2001/10/16 19:37:59	1.6
  +++ XMLScanner.java	2001/10/23 08:01:52	1.7
  @@ -94,7 +94,7 @@
    * @author Arnaud  Le Hors, IBM
    * @author Eric Ye, IBM
    *
  - * @version $Id: XMLScanner.java,v 1.6 2001/10/16 19:37:59 neilg Exp $
  + * @version $Id: XMLScanner.java,v 1.7 2001/10/23 08:01:52 andyc Exp $
    */
   public abstract class XMLScanner 
       implements XMLComponent {
  @@ -821,6 +821,10 @@
                   else if (c == '<') {
                       reportFatalError("LessthanInAttValue",
                                        new Object[] { null, atName });
  +                    fEntityScanner.scanChar();
  +                    if (entityDepth == fEntityDepth) {
  +                        fStringBuffer2.append((char)c);
  +                    }
                   }
                   else if (c == '%' || c == ']') {
                       fEntityScanner.scanChar();
  @@ -833,22 +837,12 @@
                                              + fStringBuffer.toString() + "\"");
                       }
                   }
  -                else if (c == '\r') {
  -                    // This happens when parsing the entity replacement text of
  -                    // an entity which had a character reference &#13; in its
  -                    // literal entity value. The character is normalized to
  -                    // #x20 and collapsed per the normal rules.
  +                else if (c == '\n' || c == '\r') {
                       fEntityScanner.scanChar();
                       fStringBuffer.append(' ');
  -                    fStringBuffer.append((char)c);
                       if (entityDepth == fEntityDepth) {
  -                        fStringBuffer2.append((char)c);
  +                        fStringBuffer2.append('\n');
                       }
  -                    if (DEBUG_ATTR_NORMALIZATION) {
  -                        System.out.println("** valueG: \""
  -                                           + fStringBuffer.toString()
  -                                           + "\"");
  -                    }
                   }
                   else if (c != -1 && XMLChar.isHighSurrogate(c)) {
                       if (scanSurrogates(fStringBuffer3)) {
  @@ -867,46 +861,17 @@
                       reportFatalError("InvalidCharInAttValue",
                                        new Object[] {Integer.toString(c, 16)});
                       fEntityScanner.scanChar();
  -                }
  -                // the following is to handle quotes we get from entities
  -                // which we must not confused with the end quote
  -                while (true) {
  -                    c = fEntityScanner.scanLiteral(quote, value);
  -                    if (DEBUG_ATTR_NORMALIZATION) {
  -                        System.out.println("scanLiteral -> \"" +
  -                                           value.toString() + "\"");
  -                    }
  -                    //fStringBuffer2.append(value);
  -                    normalizeWhitespace(value);
  -                    if (DEBUG_ATTR_NORMALIZATION) {
  -                        System.out.println("normalizeWhitespace -> \""
  -                                           + value.toString()
  -                                           + "\"");
  -                    }
  -                    // this is: !(c == quote && entityDepth != fEntityDepth)
  -                    if (c != quote || entityDepth == fEntityDepth) {
  -                        break;
  -                    }
  -                    fStringBuffer.append(value);
  -                    if (DEBUG_ATTR_NORMALIZATION) {
  -                        System.out.println("** valueK: \""
  -                                           + fStringBuffer.toString()
  -                                           + "\"");
  -                    }
  -                    fEntityScanner.scanChar();
  -                    fStringBuffer.append((char)c);
                       if (entityDepth == fEntityDepth) {
                           fStringBuffer2.append((char)c);
                       }
  -                    if (DEBUG_ATTR_NORMALIZATION) {
  -                        System.out.println("** valueL: \""
  -                                           + fStringBuffer.toString()
  -                                           + "\"");
  -                    }
                   }
  -            } while (c != quote);
  +                c = fEntityScanner.scanLiteral(quote, value);
  +                if (entityDepth == fEntityDepth) {
  +                    fStringBuffer2.append(value);
  +                }
  +                normalizeWhitespace(value);
  +            } while (c != quote || entityDepth != fEntityDepth);
               fStringBuffer.append(value);
  -            fStringBuffer2.append(value);
               if (DEBUG_ATTR_NORMALIZATION) {
                   System.out.println("** valueN: \""
                                      + fStringBuffer.toString() + "\"");
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org