提交 f747bd20 authored 作者: Thomas Mueller's avatar Thomas Mueller

The function JAVADECODE ignored characters after a non-escaped double quote.…

The function JAVADECODE ignored characters after a non-escaped double quote. This is no longer the case.
上级 cff7158b
......@@ -226,11 +226,9 @@ public class StringUtils {
StringBuilder buff = new StringBuilder(length);
for (int i = 0; i < length; i++) {
char c = s.charAt(i);
if (c == '"') {
break;
} else if (c == '\\') {
if (i >= s.length()) {
throw getFormatException(s, s.length() - 1);
if (c == '\\') {
if (i + 1 >= s.length()) {
throw getFormatException(s, i);
}
c = s.charAt(++i);
switch (c) {
......
......@@ -125,6 +125,7 @@ public class TestStringUtils extends TestBase {
}
private void testJavaString() {
assertEquals("a\"b", StringUtils.javaDecode("a\"b"));
Random random = new Random(1);
for (int i = 0; i < 1000; i++) {
int len = random.nextInt(10);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论