-
Notifications
You must be signed in to change notification settings - Fork 672
[4.x]: UrlHelper::buildQuery
decodes query parameter names resulting in invalid html attibutes
#12796
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
Comments
It looks like we’ve been decoding params via cms/src/templates/_layouts/element.html Line 104 in 89b54ed
But that code got refactored away a while ago, and nothing related to entry publishing is relying on that behavior anymore. So I’ve just deprecated |
I'll mention that this now breaks a URL that contains shorthand Twig (like you mention For example, people want to use But this now encodes the braces to be We'll work our way around it for now, but just wanted to flag this. |
Also note that this breaks the multi-site dropdown for things like Globals, where changing the site results in:
Due to the use of |
Cheers for the fix - #13603 |
@engram-design Yep! Thanks for pointing it out. 4.5.2 is out with this change reverted. |
Just a heads up in case anyone stumbles across this issue like I did - I think this change was also breaking the Dukt Social plugin (updating to 4.5.2 fixes the issue). Slashes in the parameter of the "Redirect URI" it generates (for Google login, at least) were getting encoded to |
What happened?
Description
UrlHelper::buildQuery
decodes query parameter names resulting in invalid html attibutes. Square brackets are not allowed as part of the url and must be encoded.Steps to reproduce
In a twig template
Expected behavior
should produce
/example?catIds%5B0%5D=1&catIds%5B1%5D=2&catIds%5B2%5D=3
Actual behavior
instead it produces:
/example?catIds[0]=1&catIds[1]=2&catIds[2]=3
Possible Fix
I'm pretty sure this line is the issue: https://github.com/craftcms/cms/blob/develop/src/helpers/UrlHelper.php#L87
Commenting it out fixes the issue… but I haven't tested side-effects.
Craft CMS version
4.4
PHP version
8.2
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
No response
The text was updated successfully, but these errors were encountered: