Gamebuster19901 commented on a change in pull request #644:
URL: https://github.com/apache/logging-log4j2/pull/644#discussion_r775173387
##########
File path:
log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/StrSubstitutorTest.java
##########
@@ -249,4 +249,37 @@ public void
testTopLevelLookupsWithoutRecursiveEvaluationAndDefaultValueLookup()
subst.setRecursiveEvaluationAllowed(false);
assertEquals("two",
subst.replace("${lower:${ctx:key1:-${ctx:key2}}}"));
}
+
+ @Test
+ public void testRecursionLimit() {
+ final Map<String, String> map = new HashMap<>();
+ for (int i = 0; i < 15; i++) {
+ int next = i + 1;
+ map.put("key" + i, "${key" + next +"}");
+ }
+ map.put("key15", "finalVal");
+ final StrLookup lookup = new Interpolator(new MapLookup(map));
+ final StrSubstitutor subst = new StrSubstitutor(lookup);
+ subst.setRecursiveEvaluationAllowed(true);
+ subst.setEnableSubstitutionInVariables(false);
Review comment:
Perhaps include a test which is the opposite of this. I.E. for when
recursive evaluation is disabled, but substitution is allowed, as a sanity
check.
--
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]