Skip to content

Commit

Permalink
[MNG-8388] Fix escape characters being replaced to change the origina…
Browse files Browse the repository at this point in the history
…l 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>
  • Loading branch information
CrazyHZM and gnodet authored Dec 5, 2024
1 parent 01e4725 commit d6edb02
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ public static String unescape(@Nullable String val) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ void testSubstitutionEscape() {
assertEquals("${a}", substVars("$\\{a${#}\\}", "b"));
assertEquals("${a}", substVars("$\\{a\\}${#}", "b"));
assertEquals("${a}", substVars("$\\{a\\}", "b"));
assertEquals("\\\\", substVars("\\\\", "b"));
}

@Test
Expand Down

0 comments on commit d6edb02

Please sign in to comment.