Skip to content

Commit d3295f1

Browse files
committed
Add checks for additional invalid literals
1 parent e57701e commit d3295f1

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/jv_parse.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,10 @@ static pfunc check_literal(struct jv_parser* p) {
514514
case 'f': pattern = "false"; plen = 5; v = jv_false(); break;
515515
case '\'':
516516
return "Invalid string literal; expected \", but got '";
517+
case '/':
518+
case '*':
519+
case '&':
520+
return "Invalid literal";
517521
case 'n':
518522
// if it starts with 'n', it could be a literal "nan"
519523
if (p->tokenpos != 3) {

tests/jq.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,3 +2094,15 @@ null
20942094
try fromjson catch .
20952095
"{'a': 123}"
20962096
"Invalid string literal; expected \", but got ' at line 1, column 5 (while parsing '{'a': 123}')"
2097+
2098+
try fromjson catch .
2099+
"{\"a\": /}"
2100+
"Invalid literal at line 1, column 8 (while parsing '{\"a\": /}')"
2101+
2102+
try fromjson catch .
2103+
"{\"a\": *}"
2104+
"Invalid literal at line 1, column 8 (while parsing '{\"a\": *}')"
2105+
2106+
try fromjson catch .
2107+
"{\"a\": &}"
2108+
"Invalid literal at line 1, column 8 (while parsing '{\"a\": &}')"

0 commit comments

Comments
 (0)