You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by "aizu-m (via GitHub)" <gi...@apache.org> on 2026/10/18 12:45:59 UTC
[PR] stop the jar parent-path loop in StscImporter.resolve [poi-xmlbeans]
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: dev-unsubscribe@poi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
Re: [PR] stop the jar parent-path loop in StscImporter.resolve [poi-xmlbeans]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on PR #138:
URL: https://github.com/apache/poi-xmlbeans/pull/138#issuecomment-6250383588
Merged - thanks
--
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: dev-unsubscribe@poi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
Re: [PR] stop the jar parent-path loop in StscImporter.resolve [poi-xmlbeans]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning merged PR #138:
URL: https://github.com/apache/poi-xmlbeans/pull/138
--
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: dev-unsubscribe@poi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org