Skip to content

Commit 17967f3

Browse files
ExtReMLapinjordankanter
authored andcommitted
grammars : don't allow to output unescaped new line in string (ggml-org#5885)
* Don't allow grammar json array to output unescaped new line in string * Don't allow new line in json object string
1 parent e76c232 commit 17967f3

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

grammars/json.gbnf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ array ::=
1515

1616
string ::=
1717
"\"" (
18-
[^"\\] |
18+
[^"\\\n] |
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ array ::=
2424

2525
string ::=
2626
"\"" (
27-
[^"\\] |
27+
[^"\\\n] |
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)