mirror of
https://github.com/lightbend/config.git
synced 2025-01-15 14:50:23 +08:00
Merge pull request #336 from usermindinc-sputnik/issue-335
Removes usage of Character.isISOControl in favor of ConfigImplUtil.isC0Control
This commit is contained in:
commit
58a4df8095
@ -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);
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user