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 upAudit usages of unicode case-changing methods. #17883
Conversation
highfive
commented
Jul 27, 2017
|
Heads up! This PR modifies the following files:
|
highfive
commented
Jul 27, 2017
|
r? @SimonSapin N.B.: I didn't address all the instances of |
| "origin-when-cross-origin" => Some(ReferrerPolicy::OriginWhenCrossOrigin), | ||
| "always" | "unsafe-url" => Some(ReferrerPolicy::UnsafeUrl), | ||
| "" => Some(ReferrerPolicy::NoReferrer), | ||
| match token { |
This comment has been minimized.
This comment has been minimized.
frewsxcv
Jul 27, 2017
Author
Member
should https://docs.rs/cssparser/0.18.2/cssparser/macro.match_ignore_ascii_case.html be used here?
| "origin-when-cross-origin" => Some(ReferrerPolicy::OriginWhenCrossOrigin), | ||
| "always" | "unsafe-url" => Some(ReferrerPolicy::UnsafeUrl), | ||
| "" => Some(ReferrerPolicy::NoReferrer), | ||
| match token { |
This comment has been minimized.
This comment has been minimized.
SimonSapin
Jul 27, 2017
Member
We have a match_ignore_ascii_case! macro that does this more efficiently.
This comment has been minimized.
This comment has been minimized.
| "rect" => Shape::Rectangle, | ||
| "polygon" => Shape::Rectangle, | ||
| "poly" => Shape::Polygon, | ||
| let shp: Shape = match &shape { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
On a side note, that macro seems like a pretty helpful utility. Wonder if it's deserving of its own separate crate instead of (awkwardly) in the cssparser crate |
|
Thanks! @bors-servo r+ Regarding the macro’s location, the thing is we have many such utilities and I don’t feel like dealing with the maintenance overhead of publishing many crates (especially if they’d be in many repositories). |
|
|
Audit usages of unicode case-changing methods. Part of #17777. <!-- 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/17883) <!-- Reviewable:end -->
|
|
Audit usages of unicode case-changing methods. Part of #17777. <!-- 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/17883) <!-- Reviewable:end -->
|
|
|
Which tests are failing here? |
|
The logs are verbose, so I scripted a thing: % curl -s http://build.servo.org/builders/linux-rel-wpt/builds/5243/steps/shell__2/logs/filtered-wpt-errorsummary.log/text | jq '{status: .status, test: .test}' -c|sort -u{"status":"CRASH","test":"/html/dom/elements/global-attributes/dataset-enumeration.html"}
{"status":"FAIL","test":"/custom-elements/reactions/DOMStringMap.html"}
{"status":"FAIL","test":"/html/dom/elements/global-attributes/custom-attrs.html"}
{"status":"FAIL","test":"/html/dom/elements/global-attributes/dataset-delete.html"}
{"status":"FAIL","test":"/html/dom/elements/global-attributes/dataset-get.html"}
{"status":"FAIL","test":"/html/dom/elements/global-attributes/dataset.html"}
{"status":"FAIL","test":"/html/dom/elements/global-attributes/dataset-set.html"}
{"status":"FAIL","test":"/html/dom/elements/global-attributes/data_unicode_attr.html"}
{"status":"FAIL","test":"/html/semantics/embedded-content/the-img-element/current-pixel-density/basic.html"}
{"status":"FAIL","test":"/html/semantics/embedded-content/the-img-element/environment-changes/viewport-change.html"}
{"status":"FAIL","test":"/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html"}
{"status":"FAIL","test":"/html/semantics/embedded-content/the-img-element/update-the-source-set.html"}
{"status":"TIMEOUT","test":"/dom/collections/domstringmap-supported-property-names.html"}
{"status":"TIMEOUT","test":"/html/semantics/embedded-content/the-img-element/environment-changes/viewport-change.html"} |
|
Latest force push has this change: diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs
index 05fcfcc8ba..1c1f8b8cbf 100644
--- a/components/script/dom/htmlelement.rs
+++ b/components/script/dom/htmlelement.rs
@@ -378,6 +378,7 @@ static DATA_HYPHEN_SEPARATOR: char = '\x2d';
fn to_snake_case(name: DOMString) -> DOMString {
let mut attr_name = String::with_capacity(name.len() + DATA_PREFIX.len());
+ attr_name.push_str(DATA_PREFIX);
for ch in name.chars() {
if ch.is_ascii_uppercase() {
attr_name.push(DATA_HYPHEN_SEPARATOR);@bors-servo try |
Audit usages of unicode case-changing methods. Part of #17777. <!-- 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/17883) <!-- Reviewable:end -->
|
|
|
|
Latest force push: diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs
index 1c1f8b8cbf..05683653fa 100644
--- a/components/script/dom/htmlelement.rs
+++ b/components/script/dom/htmlelement.rs
@@ -405,7 +405,7 @@ fn to_camel_case(name: &str) -> Option<DOMString> {
if has_uppercase {
return None;
}
- let mut result = String::with_capacity(name.len() - DATA_PREFIX.len());
+ let mut result = String::with_capacity(name.len().saturating_sub(DATA_PREFIX.len()));
let mut name_chars = name.chars();
while let Some(curr_char) = name_chars.next() {
//check for hyphen followed by character@bors-servo try |
Audit usages of unicode case-changing methods. Part of #17777. <!-- 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/17883) <!-- Reviewable:end -->
|
|
|
r? @SimonSapin |
|
@bors-servo r+ Thanks! Reviewed 1 of 1 files at r1, 3 of 6 files at r2, 1 of 1 files at r4, 5 of 5 files at r5. Comments from Reviewable |
|
|
Audit usages of unicode case-changing methods. Part of #17777. <!-- 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/17883) <!-- Reviewable:end -->
|
|
frewsxcv commentedJul 27, 2017
•
edited by larsbergstrom
Part of #17777.
This change is