xerces-j2/xerces-j2-CVE-2013-4002.patch

48 lines
1.8 KiB
Diff

--- src/org/apache/xerces/impl/XMLScanner.java 2013/07/03 18:25:06 1499505
+++ src/org/apache/xerces/impl/XMLScanner.java 2013/07/03 18:29:43 1499506
@@ -542,7 +542,7 @@
// document is until we scan the encoding declaration
// you cannot reliably read any characters outside
// of the ASCII range here. -- mrglavas
- String name = fEntityScanner.scanName();
+ String name = scanPseudoAttributeName();
XMLEntityManager.print(fEntityManager.getCurrentEntity());
if (name == null) {
reportFatalError("PseudoAttrNameExpected", null);
@@ -599,6 +599,35 @@
} // scanPseudoAttribute(XMLString):String
/**
+ * Scans the name of a pseudo attribute. The only legal names
+ * in XML 1.0/1.1 documents are 'version', 'encoding' and 'standalone'.
+ *
+ * @return the name of the pseudo attribute or <code>null</code>
+ * if a legal pseudo attribute name could not be scanned.
+ */
+ private String scanPseudoAttributeName() throws IOException, XNIException {
+ final int ch = fEntityScanner.peekChar();
+ switch (ch) {
+ case 'v':
+ if (fEntityScanner.skipString(fVersionSymbol)) {
+ return fVersionSymbol;
+ }
+ break;
+ case 'e':
+ if (fEntityScanner.skipString(fEncodingSymbol)) {
+ return fEncodingSymbol;
+ }
+ break;
+ case 's':
+ if (fEntityScanner.skipString(fStandaloneSymbol)) {
+ return fStandaloneSymbol;
+ }
+ break;
+ }
+ return null;
+ } // scanPseudoAttributeName()
+
+ /**
* Scans a processing instruction.
* <p>
* <pre>