Repository navigation
Fix a bug that could allow duplicate form submissions - #19649
Merged
Merged
Conversation
wpt-pr-bot
approved these changes
Oct 11, 2019
wpt-pr-bot
left a comment
Collaborator
There was a problem hiding this comment.
Already reviewed downstream.
chromium-wpt-export-bot
force-pushed
the
chromium-export-cl-1850358
branch
5 times, most recently
from
October 17, 2019 02:56
267f45c to
770ff38
Compare
Previous to this CL, and after [1], if a form Submit button had an onclick handler that also called form.submit() and did not call event.preventDefault(), the form would get submitted twice. The second request was eventually cancelled, but not before it hit the network. This behavior is specified in [2], through the "plan to navigate" mechanism. In the case of this bug, the "click" event occurs first, and changes the "planned navigation". Then, because the click handler does not preventDefault(), the default submit action is executed, which changes the "planned navigation", replacing the navigation queued by the onclick handler. Therefore, only the default submit navigation is performed. Note that there are other potential interactions which are less clearly specified, and which are not addressed in this CL. For example: <iframe id="test" name="test"></iframe> <form id=form1 target="test" action="click.html"></form> <a target="test" onclick="form1.submit()" href="href.html">Test</a> In this case, clicking the <a> link first submits the form (to click.html), and then queues a navigation to href.html. Because the navigation to href.html is specified (in [3]) to "queue a navigation", independently of the planned navigation specified in [2], it is unclear when/whether the form submission should take place. The spec ([4]) does have provisions for canceling existing navigations, but that leaves room for the form to still get to the network in this case, before getting canceled. [1] https://chromium.googlesource.com/chromium/src/+/6931ab86f19aa79abbdd0c1062084e16b5c4f0f6 [2] https://www.w3.org/TR/html52/sec-forms.html#form-submission-algorithm [3] https://html.spec.whatwg.org/#following-hyperlinks [4] https://html.spec.whatwg.org/#navigating-across-documents Bug: 977882 Change-Id: I693f3bdccb17c5e64df75c2e569fab589c02e88c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1850358 Commit-Queue: Joey Arhar <[email protected]> Reviewed-by: Kent Tamura <[email protected]> Reviewed-by: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/master@{#706782}
chromium-wpt-export-bot
force-pushed
the
chromium-export-cl-1850358
branch
from
October 17, 2019 04:26
770ff38 to
6e483e3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previous to this CL, and after [1], if a form Submit button had an
onclick handler that also called form.submit() and did not call
event.preventDefault(), the form would get submitted twice. The second
request was eventually cancelled, but not before it hit the network.
This behavior is specified in [2], through the "plan to navigate"
mechanism. In the case of this bug, the "click" event occurs first,
and changes the "planned navigation". Then, because the click handler
does not preventDefault(), the default submit action is executed,
which changes the "planned navigation", replacing the navigation
queued by the onclick handler. Therefore, only the default submit
navigation is performed.
Note that there are other potential interactions which are less
clearly specified, and which are not addressed in this CL.
For example:
<iframe id="test" name="test"></iframe>
<form id=form1 target="test" action="click.html"></form>
<a target="test" onclick="form1.submit()" href="href.html">Test</a>
In this case, clicking the <a> link first submits the form (to
click.html), and then queues a navigation to href.html. Because
the navigation to href.html is specified (in [3]) to "queue a
navigation", independently of the planned navigation specified
in [2], it is unclear when/whether the form submission should
take place. The spec ([4]) does have provisions for canceling
existing navigations, but that leaves room for the form to still
get to the network in this case, before getting canceled.
[1] https://chromium.googlesource.com/chromium/src/+/6931ab86f19aa79abbdd0c1062084e16b5c4f0f6
[2] https://www.w3.org/TR/html52/sec-forms.html#form-submission-algorithm
[3] https://html.spec.whatwg.org/#following-hyperlinks
[4] https://html.spec.whatwg.org/#navigating-across-documents
Bug: 977882
Change-Id: I693f3bdccb17c5e64df75c2e569fab589c02e88c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1850358
Commit-Queue: Joey Arhar <[email protected]>
Reviewed-by: Kent Tamura <[email protected]>
Reviewed-by: Mason Freed <[email protected]>
Cr-Commit-Position: refs/heads/master@{#706782}