GeezerVison is showing github.com — disable external entities in ParsingValidator instance parsing by jmestwa-coder · Pull Request #332 · xmlunit/xmlunit
Conversation
ParsingValidator.validateInstance parses the instance document with a validating SAX parser that resolves external entities, so a DOCTYPE in the instance can read local files or hit URLs through SYSTEM entities. The schema/DTD to validate against is resolved separately via the Handler, the instance never needs its own external entities.
Per the discussion this keeps the 2.6.0 default unchanged and adds an opt-in instead of changing behavior for everyone:
- new
setDisableExternalEntities(boolean) on ParsingValidator, default false so existing behavior is unchanged
- when enabled, turns off
external-general-entities and external-parameter-entities on the factory before the parser is created; DTD and schema validation are unaffected
- stronger security note in the class javadoc plus a package-level warning in
package-info.java covering both validators
- test flips the flag on
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
see the comments in #331 - this is the same case in that I explicitly decided to leave the defaults insecure back then.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
makes sense, I hadn't clocked that this was a documented decision back in 2.6, so I won't push to change the default. happy to close this one, or rework it into an opt-in setting / configurer like you described on #331 if that's useful. whichever you prefer.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
I hadn't clocked that this was a documented decision back in 2.6,
Don't worry, it has been hidden well enough.
I believe an opt-in and a more explicit warning in the javadocs may be fine. Together with #331 maybe the warnung should be at the package level.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
keep the 2.6.0 default of resolving external entities, add an opt-in
setter and document the XXE risk at the package and class level
|
reworked this the same way as #331: default stays as-is, added an opt-in setDisableExternalEntities(boolean) that only flips off the external-general/parameter-entity features when set. put the security warning at the package level in package-info.java so it covers both validators, with a short pointer on each class. test flips the flag on now.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
pull Bot
pushed a commit
to boost-mw-poc/xmlunit_xmlunit
that referenced
this pull request
Jun 20, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|