8073385: Bad error message on parsing illegal character in XML attribute

Reviewed-by: joehw
This commit is contained in:
Aleksei Efimov 2015-04-01 17:07:50 +03:00
parent 75f2048a84
commit c1e2102b1a
5 changed files with 102 additions and 8 deletions

View file

@ -1417,7 +1417,7 @@ implements XMLDTDScanner, XMLComponent, XMLEntityHandler {
// AttValue
boolean isVC = !fStandalone && (fSeenExternalDTD || fSeenExternalPE) ;
scanAttributeValue(defaultVal, nonNormalizedDefaultVal, atName,
fAttributes, 0, isVC);
fAttributes, 0, isVC, elName);
}
return defaultType;

View file

@ -1547,7 +1547,7 @@ public class XMLDocumentFragmentScannerImpl
scanAttributeValue(tmpStr, fTempString2,
fAttributeQName.rawname, attributes,
attIndex, isVC);
attIndex, isVC, fCurrentElement.rawname);
// content
int oldLen = attributes.getLength();

View file

@ -437,7 +437,7 @@ public class XMLNSDocumentScannerImpl
XMLString tmpStr = getString();
scanAttributeValue(tmpStr, fTempString2,
fAttributeQName.rawname, attributes,
attrIndex, isVC);
attrIndex, isVC, fCurrentElement.rawname);
String value = null;
//fTempString.toString();

View file

@ -811,6 +811,7 @@ public abstract class XMLScanner
* @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.
@ -819,13 +820,13 @@ public abstract class XMLScanner
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();
@ -951,7 +952,7 @@ public abstract class XMLScanner
}
} 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 @@ public abstract class XMLScanner
}
} 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 @@ public abstract class XMLScanner
// quote
int cquote = fEntityScanner.scanChar();
if (cquote != quote) {
reportFatalError("CloseQuoteExpected", new Object[]{atName});
reportFatalError("CloseQuoteExpected", new Object[]{eleName, atName});
}
} // scanAttributeValue()