Repository navigation
Adopt Apache Commons Secure XML for XML parsing - #201
Merged
Merged
Conversation
Roller configured its XML parsers by hand in two places: SafeSAXBuilder for JDOM, and WebloggerImpl for the XML-RPC library. The WebloggerImpl block logged an error and carried on if the parser did not accept a setting. New SecureXmlParsers takes its SAXParserFactory from Apache Commons Secure XML 1.0.0, which throws if a setting cannot be applied, and refuses document type declarations on top, as Roller did before. SafeSAXBuilder gets its readers from it, and WebloggerImpl installs it for XML-RPC, so startup fails rather than continuing with an unconfigured parser. Behaviour for ordinary documents is unchanged; SafeSAXBuilder keeps its existing settings as an overlapping layer.
Contributor
Author
|
🐞Claude Issue: PR-Review: General Issues The following issues were found but cannot be attached to a specific line in the diff:
|
Contributor
Author
|
🤖Claude:
|
Contributor
Author
|
Manually tested on the 6.1.7 integration build (Tomcat 9, JDK 11, MySQL 8). Pass.
|
ppkarwasz
reviewed
Oct 5, 2026
| @Override | ||
| public XMLReader createXMLReader() throws JDOMException { | ||
| try { | ||
| return newSAXParserFactory().newSAXParser().getXMLReader(); |
Member
There was a problem hiding this comment.
The new 1.1.0 version of Commons Secure XML, which is already under vote and will be released today, introduces SecureSAXParserFactory.newNSXMLReader().
Comment on lines
+77
to
+82
| try { | ||
| factory.setFeature(DISALLOW_DOCTYPE, true); | ||
| } catch (ParserConfigurationException | SAXException e) { | ||
| throw new IllegalStateException( | ||
| "The XML parser does not support refusing document type declarations", e); | ||
| } |
Member
There was a problem hiding this comment.
If #198 (comment) is implemented, I don't think there is a compelling reason to disable DOCTYPE. As far as I know, only SOAP and XMPP explicitly ban DOCTYPE declarations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Roller configured its XML parsers by hand in two places, with two separate feature lists:
SafeSAXBuilder, used for JDOM parsing (bookmark import, theme metadata, runtime config definitions, menus).WebloggerImpl, which set features on the XML-RPC library's sharedSAXParserFactory. If the parser did not accept a setting, it logged an error and continued.This PR moves both onto Apache Commons Secure XML 1.0.0:
SecureXmlParsersreturns a namespace-aware, non-validatingSAXParserFactoryfromSecureSAXParserFactory.newNSInstance(), and refuses document type declarations on top, as Roller did before. It throws if the configuration cannot be applied.SafeSAXBuildernow gets its readers fromSecureXmlParsers. It keeps its existing settings as an overlapping layer, so all its call sites are unchanged.WebloggerImplinstalls the same factory for XML-RPC withSAXParsers.setSAXParserFactory(...). Startup now fails instead of continuing with an unconfigured parser.The new dependency has no runtime dependencies of its own, and its NOTICE is the standard ASF one, so the release LICENSE and NOTICE files are unchanged.
Testing
SecureXmlParsersTest(5) and two newSafeSAXBuilderTestcases: ordinary namespaced documents parse, document type declarations are refused, declared external entities are not read, and the XML-RPC library uses the same configuration.mvn -pl app teston JDK 11: 332 tests, 0 failures, 1 skipped. The suite starts Roller, so the XML-RPC installation runs during it.roller.warbundlescommons-secure-xml-1.0.0.jar.Targets
roller-6.1.xfor 6.1.7. It will be cherry-picked tomasterafter the 6.1.7 release.