-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
@json does not work when there is a quoted value with commas in it followed by a comma separated list #46908
Comments
The |
uh, this is exactly what i am doing... |
There is no bug here. If you can come up with a solution for the Blade compiler to allow this then feel free to send in a PR. |
I shall do this, in my own free time. The blade compiler should never generate malformed php, full stop. Regardless of if its the "one true way" or not, it should generate correctly formed PHP or generate a proper exception describing why it is not valid. |
Laravel Version
9.50.2
PHP Version
8.1.11
Database Driver & Version
MySQL 8.0.32
Description
Using the
@json
function can cause malformed PHP in the compiled blade template.My previous issue was closed as too much emphasis seemed to be placed on the best practice of what i had distilled into a proof of concept. Attached is a more realistic example of how the @JSON function can be broken that is more in line with how views are actually used in the real world. I have managed to reproduce this several ways, if you need more examples please let me know.
In the example below $titles is an array set from the view, $names is also an array set by the view, "last name, first name" is a constant used to define parts of a JSON blob used for AJAX.
Any comma in the quoted first value causes the bug.
The error output from laravel is:
Steps To Reproduce
The text was updated successfully, but these errors were encountered: