Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement value sanitization on HTMLInputElement #18262
Conversation
highfive
commented
Aug 27, 2017
a1e26c5
to
a81a95c
|
@bors-servo try |
Implement value sanitization on HTMLInputElement https://html.spec.whatwg.org/multipage/input.html#value-sanitization-algorithm <!-- 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/18262) <!-- Reviewable:end -->
|
|
|
Ok, so the timeouts are actually moving us in the correct direction, the problem is simply that we have a buggy selection algorithm, causing |
|
r? @nox |
| @@ -176,7 +176,7 @@ impl HTMLInputElement { | |||
| .map_or_else(|| atom!(""), |a| a.value().as_atom().to_owned()) | |||
| } | |||
|
|
|||
| // https://html.spec.whatwg.org/multipage/#input-type-attr-summary | |||
| // https://html.spec.whatwg.org/multipage/#common-input-element-apis | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
KiChjang
Oct 19, 2017
Author
Member
Because the old link doesn't point to somewhere that can explain value modes.
This comment has been minimized.
This comment has been minimized.
nox
Oct 23, 2017
Member
https://html.spec.whatwg.org/multipage/input.html#dom-input-value is a better link, then.
| @@ -410,8 +410,19 @@ impl HTMLInputElementMethods for HTMLInputElement { | |||
| fn SetValue(&self, value: DOMString) -> ErrorResult { | |||
| match self.value_mode() { | |||
| ValueMode::Value => { | |||
| // Step 1. | |||
| let old_value = self.textinput.borrow().get_content(); | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
KiChjang
Oct 19, 2017
Author
Member
We need to clone the old value so that we may compare it in step 5.
This comment has been minimized.
This comment has been minimized.
nox
Oct 23, 2017
Member
No you don't, merge these two steps and use mem::replace and you don't need the clone.
| // Step 4. | ||
| self.sanitize_value(); | ||
| // Step 5. | ||
| if self.textinput.borrow().get_content() != old_value { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
KiChjang
Oct 19, 2017
Author
Member
Then I'm not sure which other method gets the content of the text input without using get_content.
| fn sanitize_value(&self) { | ||
| let new_value = match self.type_() { | ||
| atom!("text") | atom!("search") | atom!("tel") | atom!("password") => { | ||
| DOMString::from(self.textinput.borrow().get_content() |
This comment has been minimized.
This comment has been minimized.
| .collect::<String>()) | ||
| } | ||
| atom!("url") => { | ||
| DOMString::from(self.textinput.borrow().get_content() |
This comment has been minimized.
This comment has been minimized.
nox
Oct 19, 2017
Member
Make a helper function for https://infra.spec.whatwg.org/#strip-leading-and-trailing-ascii-whitespace.
| .chars() | ||
| .filter(|&c| c != '\r' && c != '\n') | ||
| .collect::<String>() | ||
| .trim_matches(char::is_whitespace)) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
KiChjang
Oct 19, 2017
Author
Member
Your suggestion doesn't match up with the spec: https://html.spec.whatwg.org/multipage/input.html#url-state-(type=url).
This comment has been minimized.
This comment has been minimized.
nox
Oct 23, 2017
Member
What?
The value sanitization algorithm is as follows: Strip newlines from the value, then strip leading and trailing ASCII whitespace from the value.
| fn sanitize_value(&self) { | ||
| let new_value = match self.type_() { | ||
| atom!("text") | atom!("search") | atom!("tel") | atom!("password") => { | ||
| DOMString::from(self.textinput.borrow().get_content() |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| .collect::<String>()) | ||
| } | ||
| atom!("url") => { | ||
| DOMString::from(self.textinput.borrow().get_content() |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@bors-servo try |
Implement value sanitization on HTMLInputElement https://html.spec.whatwg.org/multipage/input.html#value-sanitization-algorithm <!-- 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/18262) <!-- Reviewable:end -->
|
|
So the test harness does actually timeout on this test... will investigate. |
Implement value sanitization on HTMLInputElement https://html.spec.whatwg.org/multipage/input.html#value-sanitization-algorithm <!-- 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/18262) <!-- Reviewable:end -->
|
|
|
Ok, so it looks like the test SHOULD time out with these changes, because our |
|
Filed #19171 for the problem I mentioned above. |
|
@bors-servo r=nox |
|
|
Implement value sanitization on HTMLInputElement https://html.spec.whatwg.org/multipage/input.html#value-sanitization-algorithm <!-- 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/18262) <!-- Reviewable:end -->
|
|
Upstreamed from servo/servo#18262 [ci skip]
KiChjang commentedAug 27, 2017
•
edited by SimonSapin
https://html.spec.whatwg.org/multipage/input.html#value-sanitization-algorithm
This change is