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

Field flow: Keep URL params matching HTML attributes #2407

Conversation

EricDunsworth
Copy link
Member

@EricDunsworth EricDunsworth commented Jul 26, 2024

When field flow's redirect (redir) action is used, submitting causes the plugin to "transform" the currently-selected dropdown option's URL parameters into hidden input elements. The inputs are created by passing "raw" HTML strings to the jQuery object.

That setup used to play nicely with URL parameters whose keys corresponded to the names of HTML attributes (e.g. lang=anything). But it stopped working when wet-boew/wet-boew#9210 introduced DOMPurify into WET's jQuery 2.x implementation. Why? Because DOMPurify's sanitize() method filters-out name="[any HTML attribute name]" to prevent potential DOM clobbering attacks (see cure53/DOMPurify#980). End result is that jQuery ultimately returns name-less inputs to the plugin, which in turn causes affected parameters to go missing.

This fixes it by using "pure" JavaScript (instead of jQuery) to create the inputs. Also adds a query string example to the redirection demo (with a mix of key naming schemes).

Fixes #2406.

@Garneauma
Copy link
Contributor

Pre-approved upon successful review.

Copy link
Member

@duboisp duboisp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To review and fully test.

This is a patch.

components/wb-fieldflow/fieldflow.js Outdated Show resolved Hide resolved
@EricDunsworth
Copy link
Member Author

FWIW I retested locally with @duboisp's suggested change and it still worked fine 💯.

@duboisp
Copy link
Member

duboisp commented Aug 19, 2024

Pre-approved upon review and local testing.

@duboisp duboisp self-requested a review August 19, 2024 14:47
@duboisp duboisp added this to the v15.6.0 milestone Aug 19, 2024
When field flow's redirect (redir) action is used, submitting causes the plugin to "transform" the currently-selected dropdown option's URL parameters into hidden input elements. The inputs are created by passing "raw" HTML strings to the jQuery object.

That setup used to play nicely with URL parameters whose keys corresponded to the names of HTML attributes (e.g. lang=anything). But it stopped working when wet-boew/wet-boew#9210 introduced DOMPurify into WET's jQuery 2.x implementation. Why? Because DOMPurify's sanitize() method filters-out name="[any HTML attribute name]" to prevent potential DOM clobbering attacks (see cure53/DOMPurify#980). End result is that jQuery ultimately returns name-less inputs to the plugin, which in turn causes affected parameters to go missing.

This fixes it by using "pure" JavaScript (instead of jQuery) to create the inputs. Also adds a query string example to the redirection demo (with a mix of key naming schemes).

Fixes wet-boew#2406.

Co-authored-by: Pierre Dubois <[email protected]>
@EricDunsworth
Copy link
Member Author

Rebased, updated modified dates and force-pushed.

This wasn't running into any merge conflicts, but since it hadn't been tested by any project maintainers yet... I figured it'd make sense to rebase to make it node 20-friendly.

Copy link
Contributor

@Garneauma Garneauma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally. Works as intended.

components/wb-fieldflow/fieldflow.js Outdated Show resolved Hide resolved
@Garneauma Garneauma merged commit c716ad6 into wet-boew:master Aug 28, 2024
1 check passed
@MatthieuBonenfant-GOC
Copy link

Thank you all for your contribution!

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.

wb-fieldflow dropdown list removes destination page URL query parameters
4 participants