[MNG-8388] Fix escape characters being replaced to change the original configuration (#1946)

* [MNG-8388] Fix escape characters being replaced to change the original configuration

Signed-off-by: crazyhzm <crazyhzm@apache.org>

* Add unit test

---------

Signed-off-by: crazyhzm <crazyhzm@apache.org>
Co-authored-by: Guillaume Nodet <gnodet@gmail.com>
This commit is contained in:
Jermaine Hua 2024-12-06 02:36:08 +08:00 committed by GitHub
parent 01e47259d2
commit d6edb027c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View File

@ -420,7 +420,7 @@ public class DefaultInterpolator implements Interpolator {
int escape = val.indexOf(ESCAPE_CHAR);
while (escape >= 0 && escape < val.length() - 1) {
char c = val.charAt(escape + 1);
if (c == '{' || c == '}' || c == ESCAPE_CHAR) {
if (c == '{' || c == '}') {
val = val.substring(0, escape) + val.substring(escape + 1);
}
escape = val.indexOf(ESCAPE_CHAR, escape + 1);

View File

@ -98,6 +98,7 @@ class DefaultInterpolatorTest {
assertEquals("${a}", substVars("$\\{a${#}\\}", "b"));
assertEquals("${a}", substVars("$\\{a\\}${#}", "b"));
assertEquals("${a}", substVars("$\\{a\\}", "b"));
assertEquals("\\\\", substVars("\\\\", "b"));
}
@Test