Don't signal json-end-of-file for short nonempty bad JSON inputs

* src/json.c (json_parse_value): Generate a plain parse error.
* test/src/json-tests.el (json-parse-string/short): Adapt test.
This commit is contained in:
Mattias Engdegård 2024-03-31 19:19:58 +02:00
parent 734bd005aa
commit 3f4486dd76
2 changed files with 4 additions and 6 deletions

View file

@ -1655,9 +1655,9 @@ json_parse_value (struct json_parser *parser, int c)
return json_parse_number (parser, c);
else
{
int c2 = json_input_get (parser);
int c3 = json_input_get (parser);
int c4 = json_input_get (parser);
int c2 = json_input_get_if_possible (parser);
int c3 = json_input_get_if_possible (parser);
int c4 = json_input_get_if_possible (parser);
int c5 = json_input_get_if_possible (parser);
if (c == 't' && c2 == 'r' && c3 == 'u' && c4 == 'e'

View file

@ -215,11 +215,9 @@
(should-error (json-serialize ["u\u00C4\xCCv"]) :type 'wrong-type-argument))
(ert-deftest json-parse-string/short ()
:expected-result :failed
(should-error (json-parse-string "") :type 'json-end-of-file)
(should-error (json-parse-string " ") :type 'json-end-of-file)
;; BUG: currently results in `json-end-of-file' for short non-empty inputs.
(dolist (s '("a" "ab" "abc" "abcd"
(dolist (s '("a" "ab" "abc" "abcd" "\0" "\1"
"t" "tr" "tru" "truE" "truee"
"n" "nu" "nul" "nulL" "nulll"
"f" "fa" "fal" "fals" "falsE" "falsee"))