aizu-m opened a new pull request, #138:
URL: https://github.com/apache/poi-xmlbeans/pull/138
A schema loaded from a jar whose import climbs above the jar root hangs the
compiler:
XmlObject xsd = XmlObject.Factory.parse(
"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'
targetNamespace='urn:a'>"
+ "<xs:import namespace='urn:b'
schemaLocation='../../b.xsd'/></xs:schema>",
new
XmlOptions().setDocumentSourceName("jar:file:/tmp/schemas.jar!/xsd/a.xsd"));
XmlBeans.compileXsd(new XmlObject[]{xsd},
XmlBeans.getBuiltinTypeSystem(), null); // never returns
`StscImporter.resolve` removes `/..` segments after `!/` by hand. When the
segment before a `/..` sits before `!/`, the removal is skipped but the next
`indexOf("/..")` starts from the same index, so the loop finds the same segment
forever and spins at 100% CPU (CWE-835). `downloadSchema` calls `resolve`
before any download or namespace check, so this happens for any
`xs:import`/`xs:include`/`xs:redefine` of that shape in a classpath-loaded
schema, even with downloads disabled. The fix stops at that point and leaves
the `..` unresolved, so the import fails with a normal compile error. `..`
segments that stay inside the jar resolve as before.
Added `StscImporterResolveTest`. Both termination tests time out without the
fix. `./gradlew test` passes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]