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 <yutaro.ono.418@gmail.com>
This commit is contained in:
Yutaro Ohno 2023-04-05 18:33:35 +09:00
parent a64a15ba53
commit f0818aa383

View file

@ -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
}