Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] fix: Request::json() json errors when decoding empty string #52204

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

calebdw
Copy link
Contributor

@calebdw calebdw commented Jul 19, 2024

Hello!

I finally tracked down the root cause for the existing json errors in #52188.

When a FormRequest is resolved from the container it calls the FormRequest::createFrom() method with the Request object that, among other things, sets the FormRequest json from the Request json.

In the case where the Request does not have any content the Request::json() method is trying to decode an empty string as an associative array which results in a json syntax error.

This PR fixes that error by converting the empty string to an empty json array before decoding.

Thanks!

@calebdw calebdw changed the title fix: Request::json() json errors when decoding empty string [11.x] fix: Request::json() json errors when decoding empty string Jul 19, 2024
@taylorotwell taylorotwell merged commit ee1166c into laravel:11.x Jul 22, 2024
17 of 29 checks passed
@calebdw calebdw deleted the request_json branch July 22, 2024 14:34
@calebdw
Copy link
Contributor Author

calebdw commented Jul 22, 2024

Thanks!

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.

None yet

2 participants