提交 edbe6015 编写于 作者: S Skylot

fix(res): unescape new line symbol in string resources (#1030)

上级 f642e11a
......@@ -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));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册