garydgregory commented on code in PR #766:
URL: https://github.com/apache/commons-text/pull/766#discussion_r3957089010
##########
src/test/java/org/apache/commons/text/lookup/XmlStringLookupTest.java:
##########
@@ -64,25 +75,27 @@ void testBadXPath() {
@Test
void testExternalEntityOff() {
- assertThrows(IllegalArgumentException.class,
- () -> new
XmlStringLookup(XmlStringLookup.DEFAULT_XML_FEATURES, EMPTY_MAP).apply(DOC_DIR
+ "document-entity-ref.xml:/document/content"));
+ assertDoesNotLeak(
+ () -> new XmlStringLookup(EMPTY_MAP, EMPTY_MAP).apply(DOC_DIR
+ "document-entity-ref.xml:/document/content"), DATA);
}
@Test
+ @Disabled("External entities are blocked by Commons Secure XML through an
entity resolver and can no longer be re-enabled.")
void testExternalEntityOn() {
final String key = DOC_DIR +
"document-entity-ref.xml:/document/content";
assertEquals(DATA, new XmlStringLookup(EMPTY_MAP,
EMPTY_MAP).apply(key).trim());
- assertEquals(DATA, new XmlStringLookup(EMPTY_MAP,
XmlStringLookup.DEFAULT_XPATH_FEATURES).apply(key).trim());
}
@Test
void testInterpolatorExternalDtdOff() {
final StringSubstitutor stringSubstitutor =
StringSubstitutor.createInterpolator();
- assertThrows(IllegalArgumentException.class, () ->
stringSubstitutor.replace("${xml:" + DOC_DIR +
"document-external-dtd.xml:/document/content}"));
+ assertDoesNotLeak(() -> stringSubstitutor.replace("${xml:" + DOC_DIR +
"document-external-dtd.xml:/document/content}"),
+ "This is an external entity.");
}
@Test
@SetSystemProperty(key = "javax.xml.accessExternalDTD", value = "file")
+ @Disabled("External entities are blocked by Commons Secure XML through an
entity resolver and can no longer be re-enabled.")
Review Comment:
Same comment as above.
##########
src/test/java/org/apache/commons/text/lookup/XmlStringLookupTest.java:
##########
@@ -91,11 +104,12 @@ void testInterpolatorExternalDtdOn() {
@Test
void testInterpolatorExternalEntityOff() {
final StringSubstitutor stringSubstitutor =
StringSubstitutor.createInterpolator();
- assertThrows(IllegalArgumentException.class, () ->
stringSubstitutor.replace("${xml:" + DOC_DIR +
"document-entity-ref.xml:/document/content}"));
+ assertDoesNotLeak(() -> stringSubstitutor.replace("${xml:" + DOC_DIR +
"document-entity-ref.xml:/document/content}"), DATA);
}
@Test
@SetSystemProperty(key = "javax.xml.accessExternalDTD", value = "file")
+ @Disabled("External entities are blocked by Commons Secure XML through an
entity resolver and can no longer be re-enabled.")
Review Comment:
Same comment as above.
--
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]