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...@locus.apache.org on 2000/10/26 19:33:43 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl XMLDocumentScanner.java XMLScanner.java
andyc 00/10/26 10:33:43
Modified: java/src/org/apache/xerces/impl Tag: xerces_j_2
XMLDocumentScanner.java XMLScanner.java
Log:
1) Fixed bug in scanPseudoAttribute that would hang the parser
if the XMLEntityScanner#scanLiteral method stopped at a
"special" character. Now the scanner consumes the character,
as long as it isn't invalid, and keeps going.
2) Fixed keys used to report invalid characters in the
document scanner.
Revision Changes Path
No revision
No revision
1.1.2.48 +3 -3 xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLDocumentScanner.java
Index: XMLDocumentScanner.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLDocumentScanner.java,v
retrieving revision 1.1.2.47
retrieving revision 1.1.2.48
diff -u -r1.1.2.47 -r1.1.2.48
--- XMLDocumentScanner.java 2000/10/26 16:56:21 1.1.2.47
+++ XMLDocumentScanner.java 2000/10/26 17:33:42 1.1.2.48
@@ -101,7 +101,7 @@
* @author Stubs generated by DesignDoc on Mon Sep 11 11:10:57 PDT 2000
* @author Andy Clark, IBM
*
- * @version $Id: XMLDocumentScanner.java,v 1.1.2.47 2000/10/26 16:56:21 andyc Exp $
+ * @version $Id: XMLDocumentScanner.java,v 1.1.2.48 2000/10/26 17:33:42 andyc Exp $
*/
public class XMLDocumentScanner
extends XMLScanner
@@ -1053,7 +1053,7 @@
}
else if (c != -1 && XMLChar.isInvalid(c)) {
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
- "InvalidCharInContent",
+ "InvalidCharInAttValue",
new Object[] {Integer.toString(c, 16)},
XMLErrorReporter.SEVERITY_FATAL_ERROR);
fEntityScanner.scanChar();
@@ -1159,7 +1159,7 @@
int c = fEntityScanner.peekChar();
if (c != -1 && XMLChar.isInvalid(c)) {
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
- "InvalidCharInContent",
+ "InvalidCharInCDSect",
new Object[] {Integer.toString(c, 16)},
XMLErrorReporter.SEVERITY_FATAL_ERROR);
fEntityScanner.scanChar();
1.1.2.14 +30 -6 xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLScanner.java
Index: XMLScanner.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLScanner.java,v
retrieving revision 1.1.2.13
retrieving revision 1.1.2.14
diff -u -r1.1.2.13 -r1.1.2.14
--- XMLScanner.java 2000/10/23 21:39:30 1.1.2.13
+++ XMLScanner.java 2000/10/26 17:33:42 1.1.2.14
@@ -92,7 +92,7 @@
* @author Andy Clark, IBM
* @author Arnaud Le Hors, IBM
*
- * @version $Id: XMLScanner.java,v 1.1.2.13 2000/10/23 21:39:30 andyc Exp $
+ * @version $Id: XMLScanner.java,v 1.1.2.14 2000/10/26 17:33:42 andyc Exp $
*/
public abstract class XMLScanner
implements XMLComponent {
@@ -248,7 +248,7 @@
int state = STATE_VERSION;
fEntityScanner.skipSpaces();
while (fEntityScanner.peekChar() != '?') {
- String name = scanPseudoAttribute(fString);
+ String name = scanPseudoAttribute(scanningTextDecl, fString);
switch (state) {
case STATE_VERSION: {
if (name == fVersionSymbol) {
@@ -359,13 +359,20 @@
/**
* Scans a pseudo attribute.
*
- * @param value The string to fill in with the attribute value
+ * @param scanningTextDecl True if scanning this pseudo-attribute for a
+ * TextDecl; false if scanning XMLDecl. This
+ * flag is needed to report the correct type of
+ * error.
+ * @param value The string to fill in with the attribute
+ * value.
+ *
* @return The name of the attribute
*
* <strong>Note:</strong> This method uses fPseudoAttrStringBuffer, anything in it
* at the time of calling is lost.
*/
- public String scanPseudoAttribute(XMLString value)
+ public String scanPseudoAttribute(boolean scanningTextDecl,
+ XMLString value)
throws IOException, SAXException {
String name = fEntityScanner.scanName();
@@ -385,11 +392,28 @@
new Object[]{name}, XMLErrorReporter.SEVERITY_FATAL_ERROR);
}
fEntityScanner.scanChar();
- if (fEntityScanner.scanLiteral(quote, value) != quote) {
+ int c = fEntityScanner.scanLiteral(quote, value);
+ if (c != quote) {
fPseudoAttrStringBuffer.clear();
do {
fPseudoAttrStringBuffer.append(value);
- } while (fEntityScanner.scanLiteral(quote, value) != quote);
+ if (c != -1) {
+ if (c == '&' || c == '%' || c == '<') {
+ fPseudoAttrStringBuffer.append((char)fEntityScanner.scanChar());
+ }
+ else if (XMLChar.isInvalid(c)) {
+ String key = scanningTextDecl
+ ? "InvalidCharInTextDecl"
+ : "InvalidCharInXMLDecl";
+ fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
+ key,
+ new Object[] {Integer.toString(c, 16)},
+ XMLErrorReporter.SEVERITY_FATAL_ERROR);
+ fEntityScanner.scanChar();
+ }
+ }
+ c = fEntityScanner.scanLiteral(quote, value);
+ } while (c != quote);
fPseudoAttrStringBuffer.append(value);
value.setValues(fPseudoAttrStringBuffer);
}