Skip to content

Commit 3de3167

Browse files
authored
grammars : blacklists character control set (ggml-org#5888)
* Prevent control characters from being served in json string * Prevent control characters from being served in json string (array)
1 parent 82cb31e commit 3de3167

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

grammars/json.gbnf

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ array ::=
1515

1616
string ::=
1717
"\"" (
18-
[^"\\] |
18+
[^"\\\x7F\x00-\x1F] |
1919
"\\" (["\\/bfnrt] | "u" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) # escapes
2020
)* "\"" ws
2121

grammars/json_arr.gbnf

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ array ::=
2424

2525
string ::=
2626
"\"" (
27-
[^"\\] |
27+
[^"\\\x7F\x00-\x1F] |
2828
"\\" (["\\/bfnrt] | "u" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) # escapes
2929
)* "\"" ws
3030

0 commit comments

Comments
 (0)