mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Auto merge of #23472 - ffwff:master, r=cybai
Add value sanitization for input[type=email] <!-- Please describe your changes on the following line: --> Add value sanitization for input[type=email] as per the [HTML specification](https://html.spec.whatwg.org/multipage/input.html#e-mail-state-(type=email)). --- <!-- 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 part of #21810 (GitHub issue number if applicable) <!-- 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. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23472) <!-- Reviewable:end -->
This commit is contained in:
commit
69eacfa8c8
4 changed files with 20 additions and 57 deletions
|
@ -63,7 +63,7 @@ use std::cell::Cell;
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use style::attr::AttrValue;
|
use style::attr::AttrValue;
|
||||||
use style::element_state::ElementState;
|
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_SUBMIT_VALUE: &'static str = "Submit";
|
||||||
const DEFAULT_RESET_VALUE: &'static str = "Reset";
|
const DEFAULT_RESET_VALUE: &'static str = "Reset";
|
||||||
|
@ -1195,6 +1195,24 @@ impl HTMLInputElement {
|
||||||
InputType::Range => {
|
InputType::Range => {
|
||||||
value.set_best_representation_of_the_floating_point_number();
|
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());
|
||||||
|
}
|
||||||
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,8 @@
|
||||||
[email.html]
|
[email.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
[value should be sanitized: strip line breaks]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Email address validity]
|
[Email address validity]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[When the multiple attribute is removed, the user agent must run the value sanitization algorithm]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[run the value sanitization algorithm after setting a new value]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[valid value is a set of valid email addresses separated by a single ',']
|
[valid value is a set of valid email addresses separated by a single ',']
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,35 +1,23 @@
|
||||||
[type-change-state.html]
|
[type-change-state.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
[change state from hidden to email]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[change state from hidden to datetime]
|
[change state from hidden to datetime]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[change state from hidden to range]
|
[change state from hidden to range]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[change state from text to email]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[change state from text to datetime]
|
[change state from text to datetime]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[change state from text to range]
|
[change state from text to range]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[change state from search to email]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[change state from search to datetime]
|
[change state from search to datetime]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[change state from search to range]
|
[change state from search to range]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[change state from tel to email]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[change state from tel to datetime]
|
[change state from tel to datetime]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -48,9 +36,6 @@
|
||||||
[change state from email to range]
|
[change state from email to range]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[change state from password to email]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[change state from password to datetime]
|
[change state from password to datetime]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -69,9 +54,6 @@
|
||||||
[change state from datetime to url]
|
[change state from datetime to url]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[change state from datetime to email]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[change state from datetime to password]
|
[change state from datetime to password]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -108,57 +90,36 @@
|
||||||
[change state from number to range]
|
[change state from number to range]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[change state from range to email]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[change state from range to datetime]
|
[change state from range to datetime]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[change state from checkbox to email]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[change state from checkbox to range]
|
[change state from checkbox to range]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[change state from radio to email]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[change state from radio to datetime]
|
[change state from radio to datetime]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[change state from radio to range]
|
[change state from radio to range]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[change state from submit to email]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[change state from submit to datetime]
|
[change state from submit to datetime]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[change state from submit to range]
|
[change state from submit to range]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[change state from image to email]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[change state from image to datetime]
|
[change state from image to datetime]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[change state from image to range]
|
[change state from image to range]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[change state from reset to email]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[change state from reset to datetime]
|
[change state from reset to datetime]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[change state from reset to range]
|
[change state from reset to range]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[change state from button to email]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[change state from button to datetime]
|
[change state from button to datetime]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,4 @@
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[value IDL attribute of input type range with value attribute]
|
[value IDL attribute of input type range with value attribute]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[value IDL attribute of input type email without value attribute]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[value IDL attribute of input type email with value attribute]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue