Use a shared JDOM builder for bookmark and configuration parsing - #173
Open
snoopdave wants to merge 2 commits into
Open
Use a shared JDOM builder for bookmark and configuration parsing#173snoopdave wants to merge 2 commits into
snoopdave wants to merge 2 commits into
Conversation
An XML document can name resources for the parser to fetch: a document type declaration can point at an external subset, and entity declarations can point at files or URLs. Resolving those makes the parser act for whoever wrote the document, which suits Roller's own descriptors and not documents it parses from user input. SafeSAXBuilder settles that once for every retained JDOM parser rather than per call site: the document type declaration is refused, external entity and DTD resolution is switched off, and entity expansion is disabled. The OPML bookmark import, the menu parser, the runtime config parser and the theme metadata parser all build through it. Roller's own descriptors carry no document type declaration, so nothing about how they parse changes. The two JAXP access properties are applied through the reader factory and tolerated when unrecognised, because the Xerces Roller ships rejects them at the SAX layer; the parser features are what carry the behaviour. Trackback.java is deliberately left alone. Claude-Session: https://claude.ai/code/session_01A1fhY1E2PCFU6UAPXu2WtV
Move the resource-resolution demonstrations out of the committed suite. The retained tests verify that ordinary documents still parse and that any document type declaration is refused. Claude-Session: https://claude.ai/code/session_01A1fhY1E2PCFU6UAPXu2WtV
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.
Several call sites each construct their own JDOM
SAXBuilder, with inconsistentparser settings. This change consolidates them behind one shared,
consistently-configured builder.
What changed
SafeSAXBuilder(extendsSAXBuilder) configured with secure processingenabled, document type declarations disallowed, external entity and external
DTD resolution disabled, and entity expansion disabled.
(
MenuHelper,RuntimeConfigDefsParser,ThemeMetadataParser).Trackback.javauntouched; that file is removed separately.Note for the release notes: OPML documents carrying a DOCTYPE are now rejected
and will no longer import. OPML does not require a DOCTYPE.
Tests
SafeSAXBuilderTestasserts the parser contract directly, andBookmarkImportParsingTestexercises it through the import path, including thatordinary OPML still imports and that documents with external entities store no
entity content.