Skip to content

fix withDTDParsingDisabled to actually reject doctype declarations#326

Merged
bodewig merged 1 commit into
xmlunit:mainfrom
jmestwa-coder:dtd-parsing-disabled
May 31, 2026
Merged

fix withDTDParsingDisabled to actually reject doctype declarations#326
bodewig merged 1 commit into
xmlunit:mainfrom
jmestwa-coder:dtd-parsing-disabled

Conversation

@jmestwa-coder
Copy link
Copy Markdown
Contributor

withDTDParsingDisabled() set disallow-doctype-decl to false so it disabled nothing; flip it to true, and drop the now-effective call from Default which must keep parsing doctypes.

@bodewig
Copy link
Copy Markdown
Member

bodewig commented May 30, 2026

Thank you @jmestwa-coder in particular for also providing a test. I believe I wanted to disable DTD parsing by default and would thus not want to remove the line from DocumentBuilderFactoryConfigurer.Default - tests apart from your own still pass. See #91 for my line of thought back then.

The validation package has DTD parsing enabled but is sing SAXParser rather than DocumentBuilder - there I still believe DTD parsing should remain enabled.

@jmestwa-coder jmestwa-coder force-pushed the dtd-parsing-disabled branch from e1a9562 to 3a28d4e Compare May 31, 2026 07:22
@jmestwa-coder
Copy link
Copy Markdown
Contributor Author

Makes sense. Kept the line in Default so it disables DTD parsing as you intended; the method fix just makes that line actually do something now. Flipped my Default test to assert it rejects a doctype instead of allowing one, and left the SAXParser-based validation path alone.

@bodewig bodewig added this to the 2.12.0 milestone May 31, 2026
@bodewig
Copy link
Copy Markdown
Member

bodewig commented May 31, 2026

thank you

@bodewig bodewig merged commit ba255e7 into xmlunit:main May 31, 2026
@bodewig
Copy link
Copy Markdown
Member

bodewig commented May 31, 2026

While testing things before I must have done something wrong as now tests fail, which is good :-)

I'll introduce a new Configuration for the cases where you want DTD processing but no external DTDs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants