Merge pull request #336 from usermindinc-sputnik/issue-335

Removes usage of Character.isISOControl in favor of ConfigImplUtil.isC0Control
This commit is contained in:
Havoc Pennington 2015-07-09 11:45:21 -04:00
commit 58a4df8095
2 changed files with 7 additions and 3 deletions

View File

@ -32,6 +32,10 @@ final public class ConfigImplUtil {
return a.equals(b);
}
static boolean isC0Control(int codepoint) {
return (codepoint >= 0x0000 && codepoint <= 0x001F);
}
public static String renderJsonString(String s) {
StringBuilder sb = new StringBuilder();
sb.append('"');
@ -60,7 +64,7 @@ final public class ConfigImplUtil {
sb.append("\\t");
break;
default:
if (Character.isISOControl(c))
if (isC0Control(c))
sb.append(String.format("\\u%04x", (int) c));
else
sb.append(c);

View File

@ -38,7 +38,7 @@ final class Tokenizer {
return "tab";
else if (codepoint == -1)
return "end of file";
else if (Character.isISOControl(codepoint))
else if (ConfigImplUtil.isC0Control(codepoint))
return String.format("control character 0x%x", codepoint);
else
return String.format("%c", codepoint);
@ -498,7 +498,7 @@ final class Tokenizer {
} else if (c == '"') {
sbOrig.appendCodePoint(c);
break;
} else if (Character.isISOControl(c)) {
} else if (ConfigImplUtil.isC0Control(c)) {
throw problem(asString(c), "JSON does not allow unescaped " + asString(c)
+ " in quoted strings, use a backslash escape");
} else {