changeset 953:e74b3533292c

8073385: Bad error message on parsing illegal character in XML attribute Reviewed-by: joehw
author aefimov
date Thu, 09 Apr 2015 16:23:43 +0300
parents 497d106d476d
children cf6d1ebdb164
files src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java
diffstat 4 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java	Wed Apr 01 11:00:09 2015 -0700
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java	Thu Apr 09 16:23:43 2015 +0300
@@ -1418,7 +1418,7 @@
             // AttValue
             boolean isVC = !fStandalone  &&  (fSeenExternalDTD || fSeenExternalPE) ;
             scanAttributeValue(defaultVal, nonNormalizedDefaultVal, atName,
-            fAttributes, 0, isVC);
+            fAttributes, 0, isVC, elName);
         }
         return defaultType;
 
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java	Wed Apr 01 11:00:09 2015 -0700
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java	Thu Apr 09 16:23:43 2015 +0300
@@ -1546,7 +1546,7 @@
 
         scanAttributeValue(tmpStr, fTempString2,
                 fAttributeQName.rawname, attributes,
-                attIndex, isVC);
+                attIndex, isVC, fCurrentElement.rawname);
 
         // content
         int oldLen = attributes.getLength();
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java	Wed Apr 01 11:00:09 2015 -0700
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java	Thu Apr 09 16:23:43 2015 +0300
@@ -438,7 +438,7 @@
         XMLString tmpStr = getString();
         scanAttributeValue(tmpStr, fTempString2,
                 fAttributeQName.rawname, attributes,
-                attrIndex, isVC);
+                attrIndex, isVC, fCurrentElement.rawname);
 
         String value = null;
         //fTempString.toString();
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java	Wed Apr 01 11:00:09 2015 -0700
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java	Thu Apr 09 16:23:43 2015 +0300
@@ -812,6 +812,7 @@
      * @param attrIndex The index of the attribute to use from the list.
      * @param checkEntities true if undeclared entities should be reported as VC violation,
      *                      false if undeclared entities should be reported as WFC violation.
+     * @param eleName The name of element to which this attribute belongs.
      *
      * <strong>Note:</strong> This method uses fStringBuffer2, anything in it
      * at the time of calling is lost.
@@ -820,13 +821,13 @@
             XMLString nonNormalizedValue,
             String atName,
             XMLAttributes attributes, int attrIndex,
-            boolean checkEntities)
+            boolean checkEntities, String eleName)
             throws IOException, XNIException {
         XMLStringBuffer stringBuffer = null;
         // quote
         int quote = fEntityScanner.peekChar();
         if (quote != '\'' && quote != '"') {
-            reportFatalError("OpenQuoteExpected", new Object[]{atName});
+            reportFatalError("OpenQuoteExpected", new Object[]{eleName, atName});
         }
 
         fEntityScanner.scanChar();
@@ -952,7 +953,7 @@
                     }
                 } else if (c == '<') {
                     reportFatalError("LessthanInAttValue",
-                            new Object[] { null, atName });
+                            new Object[] { eleName, atName });
                             fEntityScanner.scanChar();
                             if (entityDepth == fEntityDepth && fNeedNonNormalizedValue) {
                                 fStringBuffer2.append((char)c);
@@ -987,7 +988,7 @@
                     }
                 } else if (c != -1 && isInvalidLiteral(c)) {
                     reportFatalError("InvalidCharInAttValue",
-                            new Object[] {Integer.toString(c, 16)});
+                            new Object[] {eleName, atName, Integer.toString(c, 16)});
                             fEntityScanner.scanChar();
                             if (entityDepth == fEntityDepth && fNeedNonNormalizedValue) {
                                 fStringBuffer2.append((char)c);
@@ -1016,7 +1017,7 @@
         // quote
         int cquote = fEntityScanner.scanChar();
         if (cquote != quote) {
-            reportFatalError("CloseQuoteExpected", new Object[]{atName});
+            reportFatalError("CloseQuoteExpected", new Object[]{eleName, atName});
         }
     } // scanAttributeValue()