mirror of
https://github.com/hapifhir/org.hl7.fhir.core.git
synced 2025-02-09 14:24:44 +00:00
fix issue with json unicode whitespace enscaping
This commit is contained in:
parent
6e27c45d54
commit
3ee9533121
@ -1032,6 +1032,10 @@ public class Utilities {
|
|||||||
|
|
||||||
|
|
||||||
public static String escapeJson(String value) {
|
public static String escapeJson(String value) {
|
||||||
|
return escapeJson(value, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String escapeJson(String value, boolean escapeUnicodeWhitespace) {
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
@ -1049,7 +1053,7 @@ public class Utilities {
|
|||||||
b.append("\\\\");
|
b.append("\\\\");
|
||||||
else if (c == ' ')
|
else if (c == ' ')
|
||||||
b.append(" ");
|
b.append(" ");
|
||||||
else if (c == '\r' || c == '\n') { // was isWhitespace(c), but this escapes unicode characters, and seems unnecessary
|
else if ((c == '\r' || c == '\n') || (isWhitespace(c) && escapeUnicodeWhitespace)) {
|
||||||
b.append("\\u"+Utilities.padLeft(Integer.toHexString(c), '0', 4));
|
b.append("\\u"+Utilities.padLeft(Integer.toHexString(c), '0', 4));
|
||||||
} else if (((int) c) < 32)
|
} else if (((int) c) < 32)
|
||||||
b.append("\\u" + Utilities.padLeft(Integer.toHexString(c), '0', 4));
|
b.append("\\u" + Utilities.padLeft(Integer.toHexString(c), '0', 4));
|
||||||
|
@ -682,7 +682,7 @@ public class JsonParser {
|
|||||||
break;
|
break;
|
||||||
case STRING:
|
case STRING:
|
||||||
b.append("\"");
|
b.append("\"");
|
||||||
b.append(Utilities.escapeJson(((JsonString) e).getValue()));
|
b.append(Utilities.escapeJson(((JsonString) e).getValue(), false));
|
||||||
b.append("\"");
|
b.append("\"");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user