Skip to content

Commit

Permalink
Merge pull request lightbend#336 from usermindinc-sputnik/issue-335
Browse files Browse the repository at this point in the history
Removes usage of Character.isISOControl in favor of ConfigImplUtil.isC0Control
  • Loading branch information
havocp committed Jul 9, 2015
2 parents 6d2d965 + 05cbb65 commit 58a4df8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ else if (a == b) // catches null == null plus optimizes identity case
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('"');
Expand Down Expand Up @@ -60,7 +64,7 @@ public static String renderJsonString(String s) {
sb.append("\\t");
break;
default:
if (Character.isISOControl(c))
if (isC0Control(c))
sb.append(String.format("\\u%04x", (int) c));
else
sb.append(c);
Expand Down
4 changes: 2 additions & 2 deletions config/src/main/java/com/typesafe/config/impl/Tokenizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ else if (codepoint == '\t')
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);
Expand Down Expand Up @@ -498,7 +498,7 @@ private Token pullQuotedString() throws ProblemException {
} 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 {
Expand Down

0 comments on commit 58a4df8

Please sign in to comment.