aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2019-05-30 09:04:50 -0400
committerGitHub <noreply@github.com>2019-05-30 09:04:50 -0400
commit69eacfa8c82f7a5e38098f46138d35b706e47917 (patch)
tree708a70f39c96b7cbc9fc46c1c8065639d776172e /components/script/dom
parent5e461853a1df28331d4a2f8b385dba0457d8da34 (diff)
parent3508140929391d9991add362c385bab1adc580a2 (diff)
downloadservo-69eacfa8c82f7a5e38098f46138d35b706e47917.tar.gz
servo-69eacfa8c82f7a5e38098f46138d35b706e47917.zip
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 -->
Diffstat (limited to 'components/script/dom')
-rwxr-xr-xcomponents/script/dom/htmlinputelement.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs
index a7d73dd404e..26a5c41a26c 100755
--- a/components/script/dom/htmlinputelement.rs
+++ b/components/script/dom/htmlinputelement.rs
@@ -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());
+ }
+ },
_ => (),
}
}