Repository navigation
Use the registered SAX parser feature names - #16392
Conversation
SpringIOUtils and the HTTP test client's XmlUtils set their parser features with https://xml.org/... and https://apache.org/... names. The parser only recognises the http:// forms, so every setFeature call was rejected and the exception swallowed, leaving only secure processing in effect. Documents that reference an external DTD or external entity then failed to parse instead of having the reference skipped. Use the http:// names so the features apply as intended. DOCTYPE declarations remain allowed.
🚨 TestLens detected 1 failed test 🚨Here is what you can do:
Test SummaryCI / Build Grails Forge (17) > :grails-forge-cli:test [grails-forge]
🏷️ Commit: 6f3ff26 Test FailuresCreateControllerCommandSpec > test app with controller (:grails-forge-cli:test [grails-forge] in CI / Build Grails Forge (17))CreateControllerCommandSpec > test app with controller (:grails-forge-cli:test [grails-forge] in CI / Build Grails Forge (17) | Attempt 1/2)Rerun ControlsSelect tests to mute in this pull request:
Reuse successful test results:
Click the checkbox to trigger a rerun:
Learn more about TestLens at testlens.app/docs. |
jdaugherty
left a comment
There was a problem hiding this comment.
We added an enum for the feature names in 8.x, can we backport that same enum in 7.x?
|
I kept this to the literal fix on purpose. Backporting |
Summary
SpringIOUtils.createParserFactory()(grails-gradle-model) and the HTTP test client'sXmlUtilsset their SAX parser features withhttps://xml.org/...andhttps://apache.org/...names. The parser only recognises the registeredhttp://forms, so everysetFeaturecall was rejected withSAXNotRecognizedExceptionand the emptycatchswallowed it. OnlyFEATURE_SECURE_PROCESSINGtook effect.Secure processing makes the JDK parser refuse to read external resources, but it does so by throwing. As a result, any document that referenced an external DTD or an external entity failed to parse instead of having the reference skipped. That includes descriptors with a DOCTYPE pointing at a DTD URL (for example the JSP 1.2 TLD form), parsed through
createXmlSlurper().This is the narrow 7.0.x counterpart of the identifier correction in #16331 on
8.0.x. The rest of #16331 (rejecting DOCTYPE by default, thegrails.xml.allowDocTypeDeclarationsetting, the strict/tolerant parser split andXmlParserFeature) changes behaviour and stays on8.0.x.Changes
SpringIOUtilsandXmlUtilsuse the registeredhttp://feature names. Every feature keeps the value 7.0.x already sets:Testing
SpringIOUtilsSpecingrails-gradle/model, adapted from Fix SAX parser feature URIs and reject DOCTYPE declarations #16331 to 7.0.x behaviour. Five of its eight features fail without the fix, with "External DTD" or "External Entity" parse errors.XmlUtilsSpecandTestHttpResponseSpecexpected the old parse error for an external entity; they now check that the file contents are not included.XmlUtilsSpecgains the external parameter entity and external DTD cases. The four updated features fail without the fix.:grails-gradle-model:test(57 tests) and:grails-testing-support-http-client:test(106 tests) pass.SpringIOUtilscaller modules pass:grails-converters,grails-core,grails-web-databindingandgrails-test-suite-web.codeStyleandgrails-gradle's:grails-gradle-model:codeStylepass.Merge-up note
These files were reworked on
8.0.xby #16331. When7.0.xis merged up, keep the8.0.xside forSpringIOUtils.java,XmlUtils.groovy,SpringIOUtilsSpec,XmlUtilsSpecandTestHttpResponseSpec.