You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2004/01/16 18:11:41 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/dom CoreDocumentImpl.java

mrglavas    2004/01/16 09:11:41

  Modified:    java/src/org/apache/xerces/dom CoreDocumentImpl.java
  Log:
  Fixing Bug #26198:
  http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26198
  
  Supplemental characters are allowed to appear in XML 1.1 names.
  We weren't checking for surrogates so we were rejecting any
  names that contained them. Instead of looping over the strings,
  use XMLChar and XML11Char to determine if a name is well-formed.
  This is better anyways. Reimplementing these checks elsewhere
  in the code is error prone.
  
  
  Revision  Changes    Path
  1.60      +15 -75    xml-xerces/java/src/org/apache/xerces/dom/CoreDocumentImpl.java
  
  Index: CoreDocumentImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/CoreDocumentImpl.java,v
  retrieving revision 1.59
  retrieving revision 1.60
  diff -u -r1.59 -r1.60
  --- CoreDocumentImpl.java	17 Nov 2003 13:48:40 -0000	1.59
  +++ CoreDocumentImpl.java	16 Jan 2004 17:11:41 -0000	1.60
  @@ -2325,65 +2325,26 @@
       }
       
       /**
  -     * @param n
  -     * @param data
  +     * Checks if the given qualified name is legal with respect 
  +     * to the version of XML to which this document must conform.
  +     * 
  +     * @param prefix prefix of qualified name
  +     * @param local local part of qualified name
        */
  -    protected final void checkQName(String prefix,
  -    String local){
  +    protected final void checkQName(String prefix, String local) {
           if (!errorChecking) {
               return;
           }
  -        int length;
  +
  +		// check that both prefix and local part match NCName
           boolean validNCName = false;
  -        if (prefix != null) {
  -            length=prefix.length();
  -            // check that prefix is NCName
  -            if(!xml11Version){
  -                validNCName=XMLChar.isNCNameStart(prefix.charAt(0));
  -            }else{
  -                validNCName=XML11Char.isXML11NCNameStart(prefix.charAt(0));
  -            }
  -            
  -            if (!validNCName) {
  -                String msg =
  -                DOMMessageFormatter.formatMessage(
  -                DOMMessageFormatter.DOM_DOMAIN,
  -                "INVALID_CHARACTER_ERR",
  -                null);
  -                throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
  -            }
  -            validNCName = false; //reuse
  -            
  -            //TODO :: pass position of the invalid char in msg
  -            //otherwise it doesnot make sense to use this forloop.
  -            for (int i = 1; i < length; i++) {
  -                
  -                if(!xml11Version){
  -                    validNCName = XMLChar.isNCName(prefix.charAt(i));
  -                }else{
  -                    validNCName = XML11Char.isXML11NCName(prefix.charAt(i));
  -                }
  -                
  -                if (!validNCName) {
  -                    String msg =
  -                    DOMMessageFormatter.formatMessage(
  -                    DOMMessageFormatter.DOM_DOMAIN,
  -                    "INVALID_CHARACTER_ERR",
  -                    null);
  -                    throw new DOMException(
  -                    DOMException.INVALID_CHARACTER_ERR,
  -                    msg);
  -                }
  -            }
  +        if (!xml11Version) {
  +            validNCName = (prefix == null || XMLChar.isValidNCName(prefix)) 
  +                && XMLChar.isValidNCName(local);
           }
  -        length = local.length();
  -        // check local part
  -        validNCName = false;
  -        
  -        if(!xml11Version) {
  -            validNCName = XMLChar.isNCNameStart(local.charAt(0));
  -        }else{
  -            validNCName = XML11Char.isXML11NCNameStart(local.charAt(0));
  +        else {
  +            validNCName = (prefix == null || XML11Char.isXML11ValidNCName(prefix))
  +                && XML11Char.isXML11ValidNCName(local);
           }
           
           if (!validNCName) {
  @@ -2394,27 +2355,6 @@
               "INVALID_CHARACTER_ERR",
               null);
               throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
  -        }
  -        
  -        validNCName = false;
  -        
  -        //TODO :: pass position of the invalid char in msg
  -        //otherwise it doesnot make sense to use this forloop.
  -        
  -        for (int i = 1; i < length; i++) {
  -            if(!xml11Version){
  -                validNCName = XMLChar.isNCName(local.charAt(i));
  -            }else{
  -                validNCName = XML11Char.isXML11NCName(local.charAt(i));
  -            }
  -            if (!validNCName) {
  -                String msg =
  -                DOMMessageFormatter.formatMessage(
  -                DOMMessageFormatter.DOM_DOMAIN,
  -                "INVALID_CHARACTER_ERR",
  -                null);
  -                throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
  -            }
           }
       }
       
  
  
  

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