From d03120b3a480224d9553e9e229788cf990e9cf77 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Sat, 11 Oct 2014 19:28:54 +0530 Subject: [PATCH] Filter out buttons which aren't the submitter while constructing the dataset --- components/script/dom/htmlformelement.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 678a090e69b..813dc8beb95 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -222,7 +222,7 @@ impl<'a> HTMLFormElementHelpers for JSRef<'a, HTMLFormElement> { script_chan.send(TriggerLoadMsg(win.page().id, load_data)); } - fn get_form_dataset(self, _submitter: Option) -> Vec { + fn get_form_dataset<'b>(self, submitter: Option>) -> Vec { fn clean_crlf(s: &str) -> DOMString { // https://html.spec.whatwg.org/multipage/forms.html#constructing-the-form-data-set // Step 4 @@ -286,6 +286,12 @@ impl<'a> HTMLFormElementHelpers for JSRef<'a, HTMLFormElement> { } let mut value = input.Value(); + let is_submitter = match submitter { + Some(InputElement(s)) => { + input == s + }, + _ => false + }; match ty.as_slice() { "image" => None, // Unimplemented "radio" | "checkbox" => { @@ -298,6 +304,8 @@ impl<'a> HTMLFormElementHelpers for JSRef<'a, HTMLFormElement> { value: value }) }, + // Discard buttons which are not the submitter + "submit" | "button" | "reset" if !is_submitter => None, "file" => None, // Unimplemented _ => Some(FormDatum { ty: ty,