Skip to content

Improved setup for XML parsing#1284

Merged
labkey-jeckels merged 4 commits intodevelopfrom
fb_miscCleanup
Feb 16, 2026
Merged

Improved setup for XML parsing#1284
labkey-jeckels merged 4 commits intodevelopfrom
fb_miscCleanup

Conversation

@labkey-jeckels
Copy link
Contributor

Rationale

We should configure XML parsers consistently. Code in this repo can't leverage XmlBeanUtil so do it manually.

Changes

  • Apply standard settings to the SAX parser

@labkey-jeckels labkey-jeckels requested review from a team and labkey-alan February 16, 2026 19:03
@labkey-jeckels labkey-jeckels self-assigned this Feb 16, 2026
@labkey-jeckels labkey-jeckels changed the title Improved validation for XML parsing and paths Improved setup for XML parsing Feb 16, 2026
Copy link
Contributor

@labkey-alan labkey-alan left a comment

Choose a reason for hiding this comment

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

Overall this looks good to me, however, I did have to search the web to find an explanation for why we want to do this. I think it would be a good idea to add a comment explaining what we're doing and why. I also left a more specific comment, but I'm not sure it's important enough to prevent merging.

SAXParser parser = SAXParserFactory.newDefaultInstance().newSAXParser();
SAXParserFactory factory = SAXParserFactory.newDefaultInstance();
factory.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true);
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
Copy link
Contributor

Choose a reason for hiding this comment

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

According to this blog post I found from 2012 these settings seem to be mutually exclusive. My understanding is that you need to either disable doctype declaration (what this line does) or disable external entities (what the following two lines do). I'm not sure it's problematic to do both though, so maybe we should keep it.

https://blog.compass-security.com/2012/08/secure-xml-parser-configuration/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, should be safe to do both, just in case.

@labkey-jeckels
Copy link
Contributor Author

Overall this looks good to me, however, I did have to search the web to find an explanation for why we want to do this. I think it would be a good idea to add a comment explaining what we're doing and why. I also left a more specific comment, but I'm not sure it's important enough to prevent merging.

Added two-way pointers here and in XmlBeansUtil, improved comments, and made them more consistent.

@labkey-jeckels labkey-jeckels merged commit a3c4b35 into develop Feb 16, 2026
5 of 7 checks passed
@labkey-jeckels labkey-jeckels deleted the fb_miscCleanup branch February 16, 2026 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants