diff --git a/src/jv_parse.c b/src/jv_parse.c index 9755b8ac47..519c2047f2 100644 --- a/src/jv_parse.c +++ b/src/jv_parse.c @@ -512,6 +512,8 @@ static pfunc check_literal(struct jv_parser* p) { switch (p->tokenbuf[0]) { case 't': pattern = "true"; plen = 4; v = jv_true(); break; case 'f': pattern = "false"; plen = 5; v = jv_false(); break; + case '\'': + return "Invalid string literal; expected \", but got '"; case 'n': // if it starts with 'n', it could be a literal "nan" if (p->tokenbuf[1] == 'u') { diff --git a/tests/jq.test b/tests/jq.test index 83d817d4e5..404994e268 100644 --- a/tests/jq.test +++ b/tests/jq.test @@ -2187,6 +2187,9 @@ try ["ok", setpath([1]; 1)] catch ["ko", .] {"hi":"hello"} ["ko","Cannot index object with number"] +try fromjson catch . +"{'a': 123}" +"Invalid string literal; expected \", but got ' at line 1, column 5 (while parsing '{'a': 123}')" # ltrimstr/1 rtrimstr/1 don't leak on invalid input #2977