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

Ignore external <form> submissions #437

Merged
merged 1 commit into from
Nov 9, 2021

Conversation

seanpdoyle
Copy link
Contributor

Closes #435

When observing <form> submissions (page-wide submissions, submissions
within a <turbo-frame>, or submissions targeting a <turbo-frame>),
ignore any with an [action] (or submitter [formaction]) attribute
that targets an external URL.

To determine whether or not a URL is "external", re-use the existing
locationIsVisitable() utility function used by the Session to
determine whether or not to navigate an <a> element.

The existing locationIsVisitable() calls depend on a "root" location
read from a PageSnapshot instance. The FrameController and
FrameRedirector do not have access to such an instance, so the <meta name="turbo-root" content="..."> element reading abstracted away by the
PageSnapshot is re-implemented across both call sites. When a
turbo-root "setting" does not exist, treat / as the root.

Closes [hotwired#435][]

When observing `<form>` submissions (page-wide submissions, submissions
within a `<turbo-frame>`, or submissions targeting a `<turbo-frame>`),
ignore any with an `[action]` (or submitter `[formaction]`) attribute
that targets an external URL.

To determine whether or not a URL is "external", re-use the existing
`locationIsVisitable()` utility function used by the `Session` to
determine whether or not to navigate an `<a>` element.

The existing `locationIsVisitable()` calls depend on a "root" location
read from a `PageSnapshot` instance. The `FrameController` and
`FrameRedirector` do not have access to such an instance, so the `<meta
name="turbo-root" content="...">` element reading abstracted away by the
`PageSnapshot` is re-implemented across both call sites. When a
`turbo-root` "setting" does not exist, treat `/` as the root.

[hotwired#435]: hotwired#435
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Form with method post and action to external url is erroneously processed by Turbo
2 participants