diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2019-12-10 07:50:27 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-10 07:50:27 -0500 |
commit | 4d5bf653f72a4ebf02c627eda7c5fa7f3744cbe8 (patch) | |
tree | 05b0d5187d3665ab7d001f2a62f548255c5d8134 /components/script/dom/htmlformelement.rs | |
parent | 8a7de32d5b8b735caf21d45d3b007ebc2644e7dd (diff) | |
parent | 7f41b1b2941824451de81febb5bee135fb863f62 (diff) | |
download | servo-4d5bf653f72a4ebf02c627eda7c5fa7f3744cbe8.tar.gz servo-4d5bf653f72a4ebf02c627eda7c5fa7f3744cbe8.zip |
Auto merge of #25217 - pshaughn:fix25150, r=jdm
hidden field named _charset_ now appears in FormData as UTF-8
<!-- Please describe your changes on the following line: -->
HTMLInputElement now has special case logic for putting a hidden field named `_charset_` in an entry set. To support this, the encoding used when constructing a form dataset is now being passed further down the callchain than it was before.
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #25150
<!-- Either: -->
- [X] There are tests for these changes
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Diffstat (limited to 'components/script/dom/htmlformelement.rs')
-rwxr-xr-x | components/script/dom/htmlformelement.rs | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 913f5f8530a..f4135ac3e0a 100755 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -357,7 +357,7 @@ impl HTMLFormElement { let encoding = self.pick_encoding(); // Step 9 - let mut form_data = match self.get_form_dataset(Some(submitter)) { + let mut form_data = match self.get_form_dataset(Some(submitter), Some(encoding)) { Some(form_data) => form_data, None => return, }; @@ -645,8 +645,14 @@ impl HTMLFormElement { } /// <https://html.spec.whatwg.org/multipage/#constructing-the-form-data-set> + /// terminology note: "form data set" = "entry list" /// Steps range from 3 to 5 - fn get_unclean_dataset(&self, submitter: Option<FormSubmitter>) -> Vec<FormDatum> { + /// 5.x substeps are mostly handled inside element-specific methods + fn get_unclean_dataset( + &self, + submitter: Option<FormSubmitter>, + encoding: Option<&'static Encoding>, + ) -> Vec<FormDatum> { let controls = self.controls.borrow(); let mut data_set = Vec::new(); for child in controls.iter() { @@ -668,7 +674,7 @@ impl HTMLFormElement { HTMLElementTypeId::HTMLInputElement => { let input = child.downcast::<HTMLInputElement>().unwrap(); - data_set.append(&mut input.form_datums(submitter)); + data_set.append(&mut input.form_datums(submitter, encoding)); }, HTMLElementTypeId::HTMLButtonElement => { let button = child.downcast::<HTMLButtonElement>().unwrap(); @@ -705,7 +711,11 @@ impl HTMLFormElement { } /// <https://html.spec.whatwg.org/multipage/#constructing-the-form-data-set> - pub fn get_form_dataset(&self, submitter: Option<FormSubmitter>) -> Option<Vec<FormDatum>> { + pub fn get_form_dataset( + &self, + submitter: Option<FormSubmitter>, + encoding: Option<&'static Encoding>, + ) -> Option<Vec<FormDatum>> { fn clean_crlf(s: &str) -> DOMString { // Step 4 let mut buf = "".to_owned(); @@ -746,7 +756,7 @@ impl HTMLFormElement { self.constructing_entry_list.set(true); // Step 3-6 - let mut ret = self.get_unclean_dataset(submitter); + let mut ret = self.get_unclean_dataset(submitter, encoding); for datum in &mut ret { match &*datum.ty { "file" | "textarea" => (), // TODO |