Skip to content

Commit e39488b

Browse files
authored
Handle non-printable control characters when escaping JSON (#1089)
* Handle non-printable control characters when escaping JSON * Add CHANGELOG
1 parent ebcdbc5 commit e39488b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
- Fix: Absence of Node.js does not hinder LSP server. https://github.com/rescript-lang/rescript-vscode/pull/1083
2626

27+
- Fix: JSON from `rescript-code-editor-analysis` was not always escaped properly, which prevented code actions from being available in certain situations https://github.com/rescript-lang/rescript-vscode/pull/1089
28+
2729
## 1.62.0
2830

2931
#### :nail_care: Polish

analysis/vendor/json/Json.ml

+4-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ let escape text =
141141
| '\b' -> Buffer.add_string buf "\\b"
142142
| '\r' -> Buffer.add_string buf "\\r"
143143
| '\t' -> Buffer.add_string buf "\\t"
144-
| c -> Buffer.add_char buf c);
144+
| c ->
145+
let code = Char.code c in
146+
if code < 0x20 then Printf.bprintf buf "\\u%04x" code
147+
else Buffer.add_char buf c);
145148
loop (i + 1))
146149
in
147150
loop 0;

0 commit comments

Comments
 (0)