Commit 8969733c authored by Yi Su's avatar Yi Su Committed by Commit Bot

Fix the bug that generating searchable URL for <form> may change DOM.

Use local variable to store value of DOM element to avoid modifying DOM, which
may cause potential danger to event-based frontend frameworks.

Bug: 433824
Change-Id: Ie7d3a9d67483738e66730a794ba798c81d515e4e
Reviewed-on: https://chromium-review.googlesource.com/c/1303729Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Yi Su <mrsuyi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603538}
parent 0a31cbaa
...@@ -217,16 +217,17 @@ function generateSearchableUrl_(form) { ...@@ -217,16 +217,17 @@ function generateSearchableUrl_(form) {
if (isSubmitElement_(element)) { if (isSubmitElement_(element)) {
// Only append the active submit element's name-value pair. // Only append the active submit element's name-value pair.
if (element === activeSubmitElement) { if (element === activeSubmitElement) {
var value = element.value;
// <input type="submit"> will have "Submit" as default "value" when // <input type="submit"> will have "Submit" as default "value" when
// submitted with empty "value" and non-empty "name". This probably // submitted with empty "value" and non-empty "name". This probably
// comes from the default label text of <input type="submit">: // comes from the default label text of <input type="submit">:
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/submit // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/submit
if (element.tagName == 'INPUT' && !element.value) { if (element.tagName == 'INPUT' && !value) {
element.value = 'Submit'; value = 'Submit';
} }
queryArgs.push( queryArgs.push(
encodeFormData_(element.name) + '=' + encodeFormData_(element.name) + '=' +
encodeFormData_(element.value)); encodeFormData_(value));
} }
continue; continue;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment