Projects
openEuler:24.03:SP1:Everything
dom4j
_service:tar_scm:CVE-2018-1000632-pre.patch
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:CVE-2018-1000632-pre.patch of Package dom4j
From 92d87957c4c4948d048ff7729c77ba10474f73ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Jirs=C3=A1k?= <filip@jirsak.org> Date: Sun, 1 Jul 2018 13:06:18 +0200 Subject: [PATCH] Fix tests with invalid QNames. --- .../java/org/dom4j/datatype/SchemaParser.java | 29 +++++++++++-------- src/test/java/org/dom4j/IteratorTest.java | 20 ++++++------- src/test/java/org/dom4j/dom/DOMTest.java | 2 +- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/dom4j/datatype/SchemaParser.java b/src/main/java/org/dom4j/datatype/SchemaParser.java index c35806ba..ab299d82 100644 --- a/src/main/java/org/dom4j/datatype/SchemaParser.java +++ b/src/main/java/org/dom4j/datatype/SchemaParser.java @@ -180,15 +180,19 @@ private void onDatatypeElement(Element xsdElement, DocumentFactory parentFactory) { String name = xsdElement.attributeValue("name"); String type = xsdElement.attributeValue("type"); - QName qname = getQName(name); - DatatypeElementFactory factory = getDatatypeElementFactory(qname); + QName qname = null; + DatatypeElementFactory factory = null; + if (name != null) { + qname = getQName(name); + factory = getDatatypeElementFactory(qname); + } if (type != null) { // register type with this element name XSDatatype dataType = getTypeByName(type); - if (dataType != null) { + if (dataType != null && factory != null) { factory.setChildElementXSDatatype(qname, dataType); } else { QName typeQName = getQName(type); @@ -205,24 +209,25 @@ private void onDatatypeElement(Element xsdElement, if (xsdSimpleType != null) { XSDatatype dataType = loadXSDatatypeFromSimpleType(xsdSimpleType); - if (dataType != null) { + if (dataType != null && factory != null) { factory.setChildElementXSDatatype(qname, dataType); } } Element schemaComplexType = xsdElement.element(XSD_COMPLEXTYPE); - if (schemaComplexType != null) { + if (schemaComplexType != null && factory != null) { onSchemaComplexType(schemaComplexType, factory); } - Iterator<Element> iter = xsdElement.elementIterator(XSD_ATTRIBUTE); - - if (iter.hasNext()) { - do { - onDatatypeAttribute(xsdElement, factory, iter - .next()); - } while (iter.hasNext()); + if (factory != null) { + Iterator<Element> iter = xsdElement.elementIterator(XSD_ATTRIBUTE); + if (iter.hasNext()) { + do { + onDatatypeAttribute(xsdElement, factory, iter + .next()); + } while (iter.hasNext()); + } } } diff --git a/src/test/java/org/dom4j/IteratorTest.java b/src/test/java/org/dom4j/IteratorTest.java index 76a2eef8..53091ae9 100644 --- a/src/test/java/org/dom4j/IteratorTest.java +++ b/src/test/java/org/dom4j/IteratorTest.java @@ -31,7 +31,7 @@ public void setUp() throws Exception { Element root = iterDocument.addElement("root"); for (int i = 0; i < NUMELE; i++) { - root.addElement("iterator test").addAttribute("instance", + root.addElement("iterator-test").addAttribute("instance", Integer.toString(i)); } } @@ -42,7 +42,7 @@ public void testElementCount() throws Exception { Element root = iterDocument.getRootElement(); assertTrue("Has root element", root != null); - List elements = root.elements("iterator test"); + List elements = root.elements("iterator-test"); int elementSize = elements.size(); assertTrue("Root has " + elementSize + " children", (elements != null) && (elementSize == NUMELE)); @@ -50,8 +50,8 @@ public void testElementCount() throws Exception { public void testPlainIteration() throws Exception { Element root = iterDocument.getRootElement(); - List elements = root.elements("iterator test"); - Iterator iter = root.elementIterator("iterator test"); + List elements = root.elements("iterator-test"); + Iterator iter = root.elementIterator("iterator-test"); int elementSize = elements.size(); int count = 0; @@ -69,8 +69,8 @@ public void testPlainIteration() throws Exception { public void testSkipAlternates() throws Exception { Element root = iterDocument.getRootElement(); - List elements = root.elements("iterator test"); - Iterator iter = root.elementIterator("iterator test"); + List elements = root.elements("iterator-test"); + Iterator iter = root.elementIterator("iterator-test"); int elementSize = elements.size(); int count = 0; @@ -89,8 +89,8 @@ public void testSkipAlternates() throws Exception { public void testNoHasNext() throws Exception { Element root = iterDocument.getRootElement(); - List elements = root.elements("iterator test"); - Iterator iter = root.elementIterator("iterator test"); + List elements = root.elements("iterator-test"); + Iterator iter = root.elementIterator("iterator-test"); int elementSize = elements.size(); int count = 0; Element e = null; @@ -121,8 +121,8 @@ public void testNoHasNext() throws Exception { public void testExtraHasNexts() throws Exception { Element root = iterDocument.getRootElement(); - List elements = root.elements("iterator test"); - Iterator iter = root.elementIterator("iterator test"); + List elements = root.elements("iterator-test"); + Iterator iter = root.elementIterator("iterator-test"); int elementSize = elements.size(); int count = 0; diff --git a/src/test/java/org/dom4j/dom/DOMTest.java b/src/test/java/org/dom4j/dom/DOMTest.java index f44d3e80..4b1f9c85 100644 --- a/src/test/java/org/dom4j/dom/DOMTest.java +++ b/src/test/java/org/dom4j/dom/DOMTest.java @@ -109,7 +109,7 @@ public void testReplaceChild() throws Exception { assertEquals(newFirst, firstChild); /* try to replace a node that doesn't exist */ - org.w3c.dom.Element badNode = document.createElement("No Child"); + org.w3c.dom.Element badNode = document.createElement("No-Child"); try { parent.replaceChild(newFirst, badNode);
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2