From f0818aa383a19aaeac02293f940928eefc4c5835 Mon Sep 17 00:00:00 2001 From: Yutaro Ohno Date: Wed, 5 Apr 2023 18:33:35 +0900 Subject: [PATCH] Remove unnecessary steps from "text/plain encoding algorithm" For "text/plain encoding algorithm", the specification [1] has changed [2] and "_charset_" is not now handled here. It's supposed to be handled in "construct the form data set" algorithm, and we've already implemented that [3]. So we now have extra steps for "text/plain encoding" algorithm. Remove no longer necessary steps from text/plain encoding algorithm so that it meets the specification. [1]: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#text/plain-encoding-algorithm [2]: https://github.com/whatwg/html/pull/3645 [3]: https://github.com/servo/servo/pull/25217 Signed-off-by: Yutaro Ohno --- components/script/dom/htmlformelement.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 80adec9718a..82075eb884f 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -659,20 +659,15 @@ impl HTMLFormElement { let mut result = String::new(); // Step 2 - let encoding = self.pick_encoding(); - - // Step 3 - let charset = encoding.name(); - - for entry in form_data.iter_mut() { - // Step 4, 5 - let value = entry.replace_value(charset); - - // Step 6 - result.push_str(&*format!("{}={}\r\n", entry.name, value)); + for entry in form_data.iter() { + let value = match &entry.value { + FormDatumValue::File(f) => f.name(), + FormDatumValue::String(s) => s, + }; + result.push_str(&format!("{}={}\r\n", entry.name, value)); } - // Step 7 + // Step 3 result }