Skip to content

json: reject trailing data after a payload - #63

Open
team-humaki wants to merge 1 commit into
go-chi:masterfrom
team-humaki:fix/42-json-trailing-data
Open

team-humaki wants to merge 1 commit into
go-chi:masterfrom
team-humaki:fix/42-json-trailing-data

Conversation

@team-humaki

Copy link
Copy Markdown

Fixes #42.

json.Decoder.Decode reads one value and ignores leftover bytes. json.Unmarshal does not. Request bodies with extra data after a JSON object now error.

Decoder.Decode accepts extra tokens after the first value. Use
json.Unmarshal so leftover garbage fails, matching encoding/json.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DecodeJSON accepts "{}\n some garbage data" incorrectly

1 participant