GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — parse Source through hardened parser in JAXPXPathEngine by jmestwa-coder · Pull Request #333 · xmlunit/xmlunit

Conversation

@jmestwa-coder

@jmestwa-coder jmestwa-coder commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

JAXPXPathEngine's Source-based xpath methods bypassed the secure parser:

  • selectNodes(String, Source) and evaluate(String, Source) handed Convert.toInputSource(s) to javax.xml.xpath.XPath.evaluate, which parses with JAXP's own default factory, so a DOCTYPE declaring an external SYSTEM entity in the source was resolved during evaluation
  • the Node-based overloads and the HasXPathMatcher/EvaluateXPathMatcher matchers already route through Convert.toNode, which uses DocumentBuilderFactoryConfigurer.Default
  • both Source methods now do the same and delegate to those overloads
    Added a regression test that feeds an external entity through both methods.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jmestwa-coder
parse Source through hardened parser in JAXPXPathEngine
c465561
@jmestwa-coder

jmestwa-coder commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

any update?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bodewig

bodewig commented Jun 20, 2026

Copy link
Copy Markdown
Member

I forgot to thank you for your contributions when commenting on the other two requests, I really appreciate it.

What would you think about allowing people to explicitly specify a DocumentBuilderFactory in JAXPXPathEngine's constructor (maybe add two new constructors) which the no-arg constructor creating one with a hardened factory by default - and then pass the configured factory down to Convert.toNode?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jmestwa-coder
allow a custom DocumentBuilderFactory in JAXPXPathEngine
96dd17d
@jmestwa-coder

jmestwa-coder commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

good idea, that reads cleaner. pushed:

  • added JAXPXPathEngine(XPathFactory, DocumentBuilderFactory) and JAXPXPathEngine(DocumentBuilderFactory)
  • the no-arg and XPathFactory-only constructors default to a factory hardened with DocumentBuilderFactoryConfigurer.Default
  • the Source overloads now pass the stored factory to Convert.toNode

also added a test that a caller-supplied factory is honored.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bodewig
bodewig reviewed Jun 20, 2026
View reviewed changes

@bodewig bodewig left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, just small nits about the tests you've added.

XMLUnit uses hamcrest matchers in its tests which should provide better error messages than assertTrue in case the assertion fails.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread xmlunit-core/src/test/java/org/xmlunit/xpath/JAXPXPathEngineTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread xmlunit-core/src/test/java/org/xmlunit/xpath/JAXPXPathEngineTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@jmestwa-coder
use hamcrest matchers and expect the exception in JAXPXPathEngine tests
d066234
@bodewig

bodewig commented Jun 20, 2026

Copy link
Copy Markdown
Member

thank you

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bodewig
bodewig merged commit c3b7c7e into xmlunit:main Jun 20, 2026
bodewig added a commit that referenced this pull request Jun 20, 2026
@bodewig
Merge pull request #334 from xmlunit/add-release-notes
f0a6fe6
add release notes for #331 #332 #333 by @jmestwa-coder
pull Bot pushed a commit to boost-mw-poc/xmlunit_xmlunit that referenced this pull request Jun 20, 2026
@bodewig
add release notes for xmlunit#331 xmlunit#332 xmlunit#333 by @jmestwa…
4765a05
…-coder
@bodewig bodewig added this to the 2.13.0 milestone Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@bodewig bodewig bodewig left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

2.13.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@jmestwa-coder @bodewig
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.