fix(res): unescape new line symbol in string resources (#1030)
This commit is contained in:
@@ -217,9 +217,9 @@ public class StringUtils {
|
||||
}
|
||||
|
||||
private static void commonEscapeAndAppend(StringBuilder sb, char c) {
|
||||
String replace = escapeXmlChar(c);
|
||||
String replace = escapeWhiteSpaceChar(c);
|
||||
if (replace == null) {
|
||||
replace = escapeWhiteSpaceChar(c);
|
||||
replace = escapeXmlChar(c);
|
||||
}
|
||||
if (replace != null) {
|
||||
sb.append(replace);
|
||||
|
||||
@@ -51,4 +51,15 @@ class StringUtilsTest {
|
||||
private void checkCharUnescape(char input, String result) {
|
||||
assertThat(stringUtils.unescapeChar(input), is('\'' + result + '\''));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResStrValueEscape() {
|
||||
checkResStrValueEscape("line\nnew line", "line\\nnew line");
|
||||
checkResStrValueEscape("can't", "can\\'t");
|
||||
checkResStrValueEscape("quote\"end", "quote\\\"end");
|
||||
}
|
||||
|
||||
private void checkResStrValueEscape(String input, String result) {
|
||||
assertThat(StringUtils.escapeResStrValue(input), is(result));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user