ppkarwasz commented on code in PR #766:
URL: https://github.com/apache/commons-text/pull/766#discussion_r3959192771
##########
src/test/java/org/apache/commons/text/lookup/StringLookupFactoryTest.java:
##########
@@ -293,12 +293,13 @@ void testXmlStringLookup() {
@Test
void testXmlStringLookupExternalEntityOff() {
- assertThrows(IllegalArgumentException.class,
- () ->
StringLookupFactory.INSTANCE.xmlStringLookup().apply(XmlStringLookupTest.DOC_DIR
+ "document-entity-ref.xml:/document/content"));
+ XmlStringLookupTest.assertDoesNotLeak(
+ () ->
StringLookupFactory.INSTANCE.xmlStringLookup().apply(XmlStringLookupTest.DOC_DIR
+ "document-entity-ref.xml:/document/content"),
+ XmlStringLookupTest.DATA);
}
@Test
- @SetSystemProperty(key = "XmlStringLookup.secure", value = "false")
+ @Disabled("External entities are blocked by Commons Secure XML through an
entity resolver and can no longer be re-enabled.")
Review Comment:
There is no way to restore the previous behavior: the public API allows
setting arbitrary **features**, but does not offer a way to call
`setEntityResolver`, which is the only way to opt-in some external resources.
I thought we agreed in
https://github.com/apache/commons-text/pull/766#discussion_r3943978584 to
introduce a mechanism that allows external fetches in a follow-up PR, but I am
happy to do it in this PR.
What mechanism do you think is appropriate?
- A system property to use `DocumentBuilderFactory.newInstance()` instead of
Commons Secure XML?
- Extend the `factoryFeatures` argument of
[`xmlStringLookup`](https://javadoc.io/doc/org.apache.commons/commons-text/latest/org/apache/commons/text/lookup/StringLookupFactory.html)
with a special key that enables external entities?
- Restrict external entities to the same folders as the XML file itself
(i.e. path fences)?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]