json: Fixes, error reporting improvements, cleanups
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest58 patches 3 repliesIn review
- v260 patches 29 repliesSuperseded
- v156 patches 105 repliesSuperseded
Changes in v3 from the cover letter · 17 lines
* Trivially rebased
* Old PATCH 41,51-52 punted to a future series
* PATCH 01 was PATCH 56 [Eric]
* PATCH 58 is new (but trivial)
* R-bys kept
* PATCH 01,06,11
- Commit message improved [Eric]
* PATCH 08,10,12,14
- from_json_str()'s unusual parameter order tidied up [Eric]
* PATCH 15,18-19,24,26,37
- Refer to RFC 8259 instead of obsolete RFC 7159
* PATCH 37-39,40
- Abbreviate interpolation as INTERP instead of INTERPOL [Eric]
* PATCH 39
- Stale comment updated
* PATCH 45
- Comma after JSON_END_OF_INPUT
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/58 | docs/interop/qmp-spec: How to force known good parser statedocs/ | +28 | 0 replies | |
| 2/58 | check-qjson: Cover multiple JSON objects in same stringtests/ | +20 | 0 replies | |
| 3/58 | check-qjson: Cover blank and lexically erroneous inputtests/ | +37 | 0 replies | |
| 4/58 | check-qjson: Cover whitespace more thoroughlytests/ | +1 | 0 replies | |
| 5/58 | qmp-cmd-test: Split off qmp-testMAINTAINERS tests/ tests/ +1 more | +219 | 0 replies | |
| 6/58 | qmp-test: Cover syntax and lexical errorstests/ tests/ tests/ | +68 | 2 replies | |
| 7/58 | test-qga: Clean up how we test QGA synchronizationtests/ tests/ tests/ | +25 | 0 replies | |
| 8/58 | check-qjson: Cover escaped characters more thoroughly, part 1tests/ | +57 | 0 replies | |
| 9/58 | check-qjson: Streamline escaped_string()'s test stringstests/ | +1 | 0 replies | |
| 10/58 | check-qjson: Cover escaped characters more thoroughly, part 2tests/ | +53 | 0 replies | |
| 11/58 | check-qjson: Consolidate partly redundant string teststests/ | +14 | 0 replies | |
| 12/58 | check-qjson: Cover UTF-8 in single quoted stringstests/ | +214 | 0 replies | |
| 13/58 | check-qjson: Simplify utf8_string()tests/ | +9 | 0 replies | |
| 14/58 | check-qjson: Fix utf8_string() to test all invalid sequencestests/ | +28 | 0 replies | |
| 15/58 | check-qjson qmp-test: Cover control characters more thoroughlytests/ tests/ | +44 | 0 replies | |
| 16/58 | check-qjson: Cover interpolation more thoroughlytests/ | +102 | 0 replies | |
| 17/58 | json: Fix lexer to include the bad character in JSON_ERROR tokenqobject/ | +2 | 0 replies | |
| 18/58 | json: Reject unescaped control charactersqobject/ tests/ tests/ | +5 | 0 replies | |
| 19/58 | json: Revamp lexer documentationqobject/ | +71 | 0 replies | |
| 20/58 | json: Tighten and simplify qstring_from_escaped_str()'s loopqobject/ | +7 | 0 replies | |
| 21/58 | check-qjson: Document we expect invalid UTF-8 to be rejectedtests/ | +71 | 0 replies | |
| 22/58 | json: Reject invalid UTF-8 sequencesinclude/ qobject/ tests/ +1 more | +122 | 0 replies | |
| 23/58 | json: Report first rather than last parse errorqobject/ | +4 | 0 replies | |
| 24/58 | json: Leave rejecting invalid UTF-8 to parserqobject/ | +2 | 0 replies | |
| 25/58 | json: Accept overlong \xC0\x80 as U+0000 ("modified UTF-8")qobject/ qobject/ tests/ | +3 | 0 replies | |
| 26/58 | json: Leave rejecting invalid escape sequences to parserqobject/ qobject/ | +37 | 0 replies | |
| 27/58 | json: Simplify parse_string()qobject/ | +19 | 0 replies | |
| 28/58 | json: Reject invalid \uXXXX, fix \u0000qobject/ tests/ | +17 | 0 replies | |
| 29/58 | json: Fix \uXXXX for surrogate pairsqobject/ tests/ | +40 | 0 replies | |
| 30/58 | check-qjson: Fix and enable utf8_string()'s disabled parttests/ | +3 | 0 replies | |
| 31/58 | json: remove useless return value from lexer/parserinclude/ include/ qobject/ +1 more | +16 | 0 replies | |
| 32/58 | json-parser: simplify and avoid JSONParserContext allocationqobject/ | +9 | 0 replies | |
| 33/58 | json: Have lexer call streamer directlyinclude/ include/ qobject/ +1 more | +17 | 0 replies | |
| 34/58 | json: Redesign the callback to consume JSON valuesinclude/ include/ monitor.c +7 more | +39 | 0 replies | |
| 35/58 | json: Don't pass null @tokens to json_parser_parse()qobject/ qobject/ | +12 | 0 replies | |
| 36/58 | json: Don't create JSON_ERROR tokens that won't be usedqobject/ | +2 | 0 replies | |
| 37/58 | json: Rename token JSON_ESCAPE & friends to JSON_INTERPinclude/ qobject/ qobject/ | +37 | 0 replies | |
| 38/58 | json: Treat unwanted interpolation as lexical errorinclude/ qobject/ qobject/ +2 more | +25 | 0 replies | |
| 39/58 | json: Pass lexical errors and limit violations to callbackinclude/ monitor.c qga/ +4 more | +33 | 0 replies | |
| 40/58 | json: Leave rejecting invalid interpolation to parserqobject/ qobject/ tests/ | +9 | 0 replies | |
| 41/58 | json: Replace %I64d, %I64u by %PRId64, %PRIu64qobject/ tests/ | +16 | 0 replies | |
| 42/58 | json: Improve names of lexer states related to numbersqobject/ | +17 | 0 replies | |
| 43/58 | qjson: Fix qobject_from_json() & friends for multiple valuesqobject/ tests/ | +17 | 0 replies | |
| 44/58 | json: Fix latent parser aborts at end of inputqobject/ | +0 | 0 replies | |
| 45/58 | json: Fix streamer not to ignore trailing unterminated structuresinclude/ qobject/ qobject/ +1 more | +15 | 0 replies | |
| 46/58 | json: Assert json_parser_parse() consumes all tokens on successqobject/ | +1 | 0 replies | |
| 47/58 | qjson: Have qobject_from_json() & friends reject empty and blankblock.c qapi/ qobject/ +1 more | +14 | 0 replies | |
| 48/58 | json: Enforce token count and size limits more tightlyqobject/ | +18 | 0 replies | |
| 49/58 | json: Streamline json_message_process_token()qobject/ | +5 | 0 replies | |
| 50/58 | json: Unbox tokens queue in JSONMessageParserinclude/ qobject/ qobject/ | +12 | 0 replies | |
| 51/58 | json: Make JSONToken opaque outside json-parser.cinclude/ include/ qobject/ +1 more | +24 | 0 replies | |
| 52/58 | qobject: Drop superfluous includes of qemu-common.hinclude/ qobject/ qobject/ +6 more | +0 | 0 replies | |
| 53/58 | json: Clean up headersinclude/ include/ monitor.c +7 more | +51 | 0 replies | |
| 54/58 | tests/drive_del-test: Fix harmless JSON interpolation bugtests/ | +6 | 0 replies | |
| 55/58 | json: Keep interpolation state in JSONParserContextqobject/ | +30 | 0 replies | |
| 56/58 | json: Improve safety of qobject_from_jsonf_nofail() & friendsqobject/ tests/ | +17 | 0 replies | |
| 57/58 | json: Support %% in JSON strings when interpolatingqobject/ tests/ | +4 | 0 replies | |
| 58/58 | json: Update references to RFC 7159 to RFC 8259include/ qapi/ qobject/ | +3 | 1 reply |
Reviews trailers per patch
All 58 patches have a Reviewed-by or Acked-by.
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.
Cover letter [Qemu-devel] [PATCH v3 00/58] json: Fixes, error reporting improvements, cleanups
JSON is such a simple language, so writing a parser should be easy, shouldn't it? Well, the evidence is in, and it's a lot of patches. Summary of fixes:
* Reject ASCII control characters in strings as RFC 7159 specifies
* Reject all invalid UTF-8 sequences, not just some
* Reject invalid \uXXXX escapes
* Implement \uXXXX surrogate pairs as specified by RFC 7159
* Don't ignore \u0000 silently, map it to \xC0\80 (modified UTF-8)
* qobject_from_json() is ridicilously broken for input containing more than one value, fix
* Don't ignore trailing unterminated structures
* Less cavalierly cruel error reporting
Topped off with tests and cleanups.
If you're into this kind of disaster relief, commit c7a3f25200c "qapi.py: Restructure lexer and parser" was even funnier.
v3:
* Trivially rebased
* Old PATCH 41,51-52 punted to a future series
* PATCH 01 was PATCH 56 [Eric]
* PATCH 58 is new (but trivial)
* R-bys kept
* PATCH 01,06,11
- Commit message improved [Eric]
* PATCH 08,10,12,14
- from_json_str()'s unusual parameter order tidied up [Eric]
* PATCH 15,18-19,24,26,37
- Refer to RFC 8259 instead of obsolete RFC 7159
* PATCH 37-39,40
- Abbreviate interpolation as INTERP instead of INTERPOL [Eric]
* PATCH 39
- Stale comment updated
* PATCH 45
- Comma after JSON_END_OF_INPUT
v2:
* Rebased
* PATCH 01,11-14,16-18,20,22-23,29-36,41,43,45-50,53-55 otherwise unchanged
* PATCH 57-60 are new
* R-bys kept unless noted otherwise
* PATCH 02
- Cover unrecognized keyword [Eric]
* PATCH 03
- Cover \r [Eric]
* PATCH 04-05
- Comments touched up [Eric]
* PATCH 06
- Use qmp_fd_send_raw() just for "\xff" [Eric]
* PATCH 07
- Plug memory leak [Eric]
* PATCH 08
- Delay adding coverage for \' until PATCH 09
* PATCH 09
- Cover \\\0
- Drop duplicated test case (editing accident) [Eric]
- Improve surrogate coverage
* PATCH 10
- Don't lose test coverage for \" and \'
- R-by dropped
* PATCH 15,27,38-39
- Cover unkown interpolation specification
- Cover attempt to interpolate into JSON string
- R-by of PATCH 15 dropped
* PATCH 19
- Tweak loop control once more
- R-by dropped
* PATCH 21,26
- Update for tweak to PATCH 19
- I might still drop redundant masking [Eric]
* PATCH 24
- Commit message improved
* PATCH 25
- Comment improvement [Eric]
- Commit message tweaked
* PATCH 28
- Fix error message to show both halves of an invalid surrogate pair
[Eric]
- Fix unpaired leading surrogate followed by \u escape [Paolo]
* PATCH 36
- I might still rename JSON_INTERPOL & friends [Eric]
* PATCH 37
- Document lexing interpolations is now optional [Eric]
- Move deletion of a redundant assignment from PATCH 51 [Eric]
* PATCH 37,42,51-52
- De-duplicate state transitions common to IN_START and IN_START_INTERPOL [Eric]
* PATCH 38
- Commit message tweaked
* PATCH 39
- More legible commit message [Eric]
- Comment fix [Eric]
* PATCH 40
- Commit message typo [Eric]
* PATCH 44
- Commit message tab damage [Eric]
* PATCH 56
- More on QGA synchronization [Eric]
- I might still move this earlier in the series
Marc-André Lureau (2):
json: remove useless return value from lexer/parser
json-parser: simplify and avoid JSONParserContext allocation
Markus Armbruster (56):
docs/interop/qmp-spec: How to force known good parser state
check-qjson: Cover multiple JSON objects in same string
check-qjson: Cover blank and lexically erroneous input
check-qjson: Cover whitespace more thoroughly
qmp-cmd-test: Split off qmp-test
qmp-test: Cover syntax and lexical errors
test-qga: Clean up how we test QGA synchronization
check-qjson: Cover escaped characters more thoroughly, part 1
check-qjson: Streamline escaped_string()'s test strings
check-qjson: Cover escaped characters more thoroughly, part 2
check-qjson: Consolidate partly redundant string tests
check-qjson: Cover UTF-8 in single quoted strings
check-qjson: Simplify utf8_string()
check-qjson: Fix utf8_string() to test all invalid sequences check-qjson qmp-test: Cover control characters more thoroughly
check-qjson: Cover interpolation more thoroughly
json: Fix lexer to include the bad character in JSON_ERROR token
json: Reject unescaped control characters
json: Revamp lexer documentation
json: Tighten and simplify qstring_from_escaped_str()'s loop
check-qjson: Document we expect invalid UTF-8 to be rejected
json: Reject invalid UTF-8 sequences
json: Report first rather than last parse error
json: Leave rejecting invalid UTF-8 to parser
json: Accept overlong \xC0\x80 as U+0000 ("modified UTF-8")
json: Leave rejecting invalid escape sequences to parser
json: Simplify parse_string()
json: Reject invalid \uXXXX, fix \u0000
json: Fix \uXXXX for surrogate pairs
check-qjson: Fix and enable utf8_string()'s disabled part
json: Have lexer call streamer directly
json: Redesign the callback to consume JSON values
json: Don't pass null @tokens to json_parser_parse()
json: Don't create JSON_ERROR tokens that won't be used
json: Rename token JSON_ESCAPE & friends to JSON_INTERP
json: Treat unwanted interpolation as lexical error
json: Pass lexical errors and limit violations to callback
json: Leave rejecting invalid interpolation to parser
json: Replace %I64d, %I64u by %PRId64, %PRIu64
json: Improve names of lexer states related to numbers
qjson: Fix qobject_from_json() & friends for multiple values
json: Fix latent parser aborts at end of input
json: Fix streamer not to ignore trailing unterminated structures
json: Assert json_parser_parse() consumes all tokens on success
qjson: Have qobject_from_json() & friends reject empty and blank
json: Enforce token count and size limits more tightly
json: Streamline json_message_process_token()
json: Unbox tokens queue in JSONMessageParser
json: Make JSONToken opaque outside json-parser.c
qobject: Drop superfluous includes of qemu-common.h
json: Clean up headers
tests/drive_del-test: Fix harmless JSON interpolation bug
json: Keep interpolation state in JSONParserContext
json: Improve safety of qobject_from_jsonf_nofail() & friends
json: Support %% in JSON strings when interpolating
json: Update references to RFC 7159 to RFC 8259
MAINTAINERS | 1 + block.c | 5 - docs/interop/qmp-spec.txt | 42 +- include/qapi/qmp/json-lexer.h | 56 -- include/qapi/qmp/json-parser.h | 36 +- include/qapi/qmp/json-streamer.h | 46 -- include/qapi/qmp/qerror.h | 3 - include/qapi/qmp/qnum.h | 2 +- include/qemu/unicode.h | 1 + monitor.c | 21 +- qapi/introspect.json | 2 +- qapi/qmp-dispatch.c | 1 - qapi/qobject-input-visitor.c | 5 - qga/main.c | 15 +- qobject/json-lexer.c | 317 ++++----- qobject/json-parser-int.h | 54 ++ qobject/json-parser.c | 379 +++++------ qobject/json-streamer.c | 126 ++-- qobject/qbool.c | 1 - qobject/qjson.c | 31 +- qobject/qlist.c | 1 - qobject/qnull.c | 1 - qobject/qnum.c | 1 - qobject/qobject.c | 1 - qobject/qstring.c | 1 - tests/Makefile.include | 3 + tests/check-qjson.c | 1058 ++++++++++++++++-------------- tests/drive_del-test.c | 8 +- tests/libqtest.c | 57 +- tests/libqtest.h | 13 + tests/qmp-cmd-test.c | 213 ++++++ tests/qmp-test.c | 252 ++----- tests/test-qga.c | 3 +- util/unicode.c | 69 +- 34 files changed, 1484 insertions(+), 1341 deletions(-) delete mode 100644 include/qapi/qmp/json-lexer.h delete mode 100644 include/qapi/qmp/json-streamer.h create mode 100644 qobject/json-parser-int.h create mode 100644 tests/qmp-cmd-test.c
Signature · 1 line
2.17.1