11 Commits

Author SHA1 Message Date
John R. Lenton
35a76969b3 store, jsonutil: move store.getStructFields to jsonutil.StructFields
It seems something like StructFields is more generally useful, so this
moves it to jsontuil so it can be reused.
2018-06-04 09:18:25 +01:00
John R. Lenton
f16f0a7e4b jsonutil/safejson: add a comment around � so it's clear it's intentional 2018-05-09 10:04:16 +01:00
John R. Lenton
d597faf1a9 jsonutil/safejson: improve documentation. 2018-05-09 09:45:11 +01:00
John R. Lenton
4972b66006 jsonutil: rename and prune back puritan (now safejson)
We agreed to rename jsonutil/puritan to jsonutil/safejson, and to cut
back its scope, to only address the most problematic fields right
while working towards validating every field down the road, using a
combination of ad-hoc parsers and field tagging.

Also, address all the review feedback (thanks pedronis, niemeyer,
and zyga).
2018-03-17 11:32:16 +00:00
John R. Lenton
b6198cea96 jsonutil/puritan: reversed removal of checks, added more tests
thanks to @bboozzoo for the de-dumbing of me.
2018-03-12 14:39:19 +00:00
John R. Lenton
3af06c93c2 jsonutil/puritan: improve test coverage
This finishes the job I started in the previous commit.
2018-03-12 09:25:54 +00:00
John R. Lenton
0f26f4a31f jsonutil/puritan: drop duplicated checks
by the time puritan gets a json []byte it's already been checked for
validity, so we don't need to check check things that are invalid json.

Added explicit tests for the checks I removed, just in case.

I didn't set out to do this, but to try to increase coverage... and
all these ifs would always stay red :-)
2018-03-12 07:21:24 +00:00
John R. Lenton
0cb50be7fe jsonutil/puritan: add some comments 2018-03-06 16:23:54 +01:00
John R. Lenton
90399d1b00 jsonutil/puritan: introducing puritan.String & etc
In some cases snapd is given a string it can't be sure is safe to print to
the user's terminal.

With this change, jsonutil will have the tools to deal with that
safely.  store/details.go and store/details_v2.go use it to decode
everything the store sends.
2018-03-06 12:13:09 +01:00
Pawel Stolowski
6d0042b019 Renamed to DecodeWithNumber. Changed error message. 2017-08-18 09:57:45 +02:00
Pawel Stolowski
ea0c8143c3 Review comments. 2017-07-31 17:47:26 +02:00