mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Add value sanitization algorithm for input[type="email"]
Handle "Multiple" attribute for email value sanitization Fix code formatting Tests for email value sanitization should pass Make failing wpt tests pass Change new_value => sanitized
This commit is contained in:
parent
84ec1316c9
commit
3508140929
4 changed files with 20 additions and 57 deletions
|
@ -63,7 +63,7 @@ use std::cell::Cell;
|
|||
use std::ops::Range;
|
||||
use style::attr::AttrValue;
|
||||
use style::element_state::ElementState;
|
||||
use style::str::split_commas;
|
||||
use style::str::{split_commas, str_join};
|
||||
|
||||
const DEFAULT_SUBMIT_VALUE: &'static str = "Submit";
|
||||
const DEFAULT_RESET_VALUE: &'static str = "Reset";
|
||||
|
@ -1195,6 +1195,24 @@ impl HTMLInputElement {
|
|||
InputType::Range => {
|
||||
value.set_best_representation_of_the_floating_point_number();
|
||||
},
|
||||
InputType::Email => {
|
||||
if !self.Multiple() {
|
||||
value.strip_newlines();
|
||||
value.strip_leading_and_trailing_ascii_whitespace();
|
||||
} else {
|
||||
let sanitized = str_join(
|
||||
split_commas(value).map(|token| {
|
||||
let mut token = DOMString::from_string(token.to_string());
|
||||
token.strip_newlines();
|
||||
token.strip_leading_and_trailing_ascii_whitespace();
|
||||
token
|
||||
}),
|
||||
",",
|
||||
);
|
||||
value.clear();
|
||||
value.push_str(sanitized.as_str());
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue