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

Prevents inputs from changing ViewTransitions' form method or action #10856

Merged
merged 2 commits into from Apr 23, 2024

Conversation

robertvanhoesel
Copy link
Contributor

Changes

Fixes #10849. Prevents inputs with a name attribute of action or method to break ViewTransitions' form submission

Before

<form action="foo">
 <input name="action" value="bar">
</form>

Submission would result in a broken route GET /[object%20HTMLInputElement] since form.action now points to an HTML element.

After

Form submission handler tests action to be a string, and if not reads the action using form.getAttribute

Testing

  • Added two additional e2e tests of scenarios that would break without this fix.
  • Existing tests enhanced my fix to have more rigorous checking of attributes

Docs

No docs changed needed

Copy link

changeset-bot bot commented Apr 23, 2024

🦋 Changeset detected

Latest commit: 631d336

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Apr 23, 2024
Copy link
Member

@martrapp martrapp left a comment

Choose a reason for hiding this comment

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

Took me a while to understand but now looks very good to me!
Also thank you very much for adding the tests!

(would only be slightly better with a capital M in formMethod ;-)

@robertvanhoesel
Copy link
Contributor Author

(would only be slightly better with a capital M in formMethod ;-)

@martrapp Oh hey that is definitely meant to have a capital M. Fixed!

@martrapp
Copy link
Member

Thank you so much ;-)!
Will give @matthewp a chance to approve, if he finds time.

Copy link
Contributor

@matthewp matthewp left a comment

Choose a reason for hiding this comment

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

wonderful tests

@matthewp matthewp merged commit 30cf82a into withastro:main Apr 23, 2024
13 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VIewTransitions break on presence of <input name="action">
3 participants