Skip to content

Replace JSON.load with JSON.parse in Grape::Json stdlib fallback#2761

Closed
dblock wants to merge 1 commit into
ruby-grape:masterfrom
dblock:fix/json-use-parse
Closed

Replace JSON.load with JSON.parse in Grape::Json stdlib fallback#2761
dblock wants to merge 1 commit into
ruby-grape:masterfrom
dblock:fix/json-use-parse

Conversation

@dblock

@dblock dblock commented Jun 10, 2026

Copy link
Copy Markdown
Member

Follow-up to #2759.

JSON.parse is the semantically correct API for parsing untrusted input. JSON.load is documented for internal serialization of trusted data (analogous to Marshal.load). The previous fix passed create_additions: false to neuter JSON.load — but that just makes it behave like JSON.parse. May as well use the right call directly.

To me it looks strange that we'd overload load with parse, so I think we don't merge this.

JSON.parse is the semantically correct API for parsing untrusted input.
JSON.load is intended for internal serialization of trusted data.
Using create_additions: false merely neutered JSON.load to behave like
JSON.parse — may as well use the right call directly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dblock dblock force-pushed the fix/json-use-parse branch from 7afd209 to c02a82e Compare June 10, 2026 21:33
@dblock dblock marked this pull request as draft June 10, 2026 21:33
@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown

Danger Report

No issues found.

View run

@ericproulx

ericproulx commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

I think this is better

@dblock dblock closed this Jun 11, 2026
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.

2 participants