Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit usages of unicode case-changing methods. #17883

Merged
merged 4 commits into from Aug 2, 2017

Conversation

@frewsxcv
Copy link
Member

frewsxcv commented Jul 27, 2017

Part of #17777.


This change is Reviewable

@highfive
Copy link

highfive commented Jul 27, 2017

Heads up! This PR modifies the following files:

  • @fitzgen: components/script/dom/document.rs, components/script/lib.rs, components/script/dom/htmlelement.rs, components/script/dom/htmlareaelement.rs, components/script/dom/blob.rs
  • @KiChjang: components/script/dom/document.rs, components/net/fetch/methods.rs, components/script/lib.rs, components/script/dom/htmlelement.rs, components/script/dom/htmlareaelement.rs and 1 more
@highfive
Copy link

highfive commented Jul 27, 2017

warning Warning warning

  • These commits modify net and script code, but no tests are modified. Please consider adding a test!
@frewsxcv
Copy link
Member Author

frewsxcv commented Jul 27, 2017

r? @SimonSapin

N.B.: I didn't address all the instances of to_uppercase, to_lowercase, etc.

@highfive highfive assigned SimonSapin and unassigned glennw Jul 27, 2017
"origin-when-cross-origin" => Some(ReferrerPolicy::OriginWhenCrossOrigin),
"always" | "unsafe-url" => Some(ReferrerPolicy::UnsafeUrl),
"" => Some(ReferrerPolicy::NoReferrer),
match token {

This comment has been minimized.

"origin-when-cross-origin" => Some(ReferrerPolicy::OriginWhenCrossOrigin),
"always" | "unsafe-url" => Some(ReferrerPolicy::UnsafeUrl),
"" => Some(ReferrerPolicy::NoReferrer),
match token {

This comment has been minimized.

Copy link
@SimonSapin

SimonSapin Jul 27, 2017

Member

We have a match_ignore_ascii_case! macro that does this more efficiently.

This comment has been minimized.

Copy link
@frewsxcv

frewsxcv Jul 27, 2017

Author Member

Addressed in 719b09c

"rect" => Shape::Rectangle,
"polygon" => Shape::Rectangle,
"poly" => Shape::Polygon,
let shp: Shape = match &shape {

This comment has been minimized.

Copy link
@SimonSapin

SimonSapin Jul 27, 2017

Member

match_ignore_ascii_case! again

This comment has been minimized.

Copy link
@frewsxcv

frewsxcv Jul 27, 2017

Author Member

Addressed in 719b09c

@frewsxcv
Copy link
Member Author

frewsxcv commented Jul 27, 2017

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

@SimonSapin
Copy link
Member

SimonSapin commented Jul 27, 2017

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).

@bors-servo
Copy link
Contributor

bors-servo commented Jul 27, 2017

📌 Commit 719b09c has been approved by SimonSapin

@bors-servo
Copy link
Contributor

bors-servo commented Jul 27, 2017

Testing commit 719b09c with merge 0de3e03...

bors-servo added a commit that referenced this pull request Jul 27, 2017
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 -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 27, 2017

💔 Test failed - linux-rel-wpt

@bors-servo
Copy link
Contributor

bors-servo commented Jul 28, 2017

Testing commit 719b09c with merge 039810d...

bors-servo added a commit that referenced this pull request Jul 28, 2017
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 -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 28, 2017

💔 Test failed - linux-rel-wpt

@frewsxcv
Copy link
Member Author

frewsxcv commented Jul 28, 2017

Which tests are failing here?

@SimonSapin
Copy link
Member

SimonSapin commented Jul 28, 2017

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"}
@frewsxcv frewsxcv force-pushed the frewsxcv:frewsxcxv-lowercase branch from 719b09c to cc6ba49 Jul 28, 2017
@frewsxcv
Copy link
Member Author

frewsxcv commented Jul 28, 2017

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

@bors-servo
Copy link
Contributor

bors-servo commented Jul 28, 2017

Trying commit cc6ba49 with merge 93ac7db...

bors-servo added a commit that referenced this pull request Jul 28, 2017
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 -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 28, 2017

💔 Test failed - linux-rel-wpt

@jdm
Copy link
Member

jdm commented Jul 28, 2017

▶ CRASH [expected OK] /html/dom/elements/global-attributes/dataset-enumeration.html
  │ 
  │ VMware, Inc.
  │ Gallium 0.4 on softpipe
  │ 3.3 (Core Profile) Mesa 12.0.1
  │ attempt to subtract with overflow (thread ScriptThread PipelineId { namespace_id: PipelineNamespaceId(0), index: PipelineIndex(0) }, at /home/servo/buildbot/slave/linux-rel-wpt/build/components/script/dom/htmlelement.rs:408)

  ▶ TIMEOUT [expected OK] /dom/collections/domstringmap-supported-property-names.html
  │ 
  │ VMware, Inc.
  │ Gallium 0.4 on softpipe
  │ 3.3 (Core Profile) Mesa 12.0.1
  └ attempt to subtract with overflow (thread ScriptThread PipelineId { namespace_id: PipelineNamespaceId(0), index: PipelineIndex(0) }, at /home/servo/buildbot/slave/linux-rel-wpt/build/components/script/dom/htmlelement.rs:408)
@frewsxcv frewsxcv force-pushed the frewsxcv:frewsxcxv-lowercase branch from cc6ba49 to befe538 Jul 29, 2017
@frewsxcv
Copy link
Member Author

frewsxcv commented Jul 29, 2017

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

@bors-servo
Copy link
Contributor

bors-servo commented Jul 29, 2017

Trying commit befe538 with merge bc4028c...

bors-servo added a commit that referenced this pull request Jul 29, 2017
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 -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 29, 2017

@frewsxcv
Copy link
Member Author

frewsxcv commented Jul 29, 2017

@SimonSapin
Copy link
Member

SimonSapin commented Aug 2, 2017

@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.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@bors-servo
Copy link
Contributor

bors-servo commented Aug 2, 2017

📌 Commit befe538 has been approved by SimonSapin

@bors-servo
Copy link
Contributor

bors-servo commented Aug 2, 2017

Testing commit befe538 with merge 5fff90c...

bors-servo added a commit that referenced this pull request Aug 2, 2017
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 -->
@bors-servo
Copy link
Contributor

bors-servo commented Aug 2, 2017

@bors-servo bors-servo merged commit befe538 into servo:master Aug 2, 2017
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@frewsxcv frewsxcv deleted the frewsxcv:frewsxcxv-lowercase branch Aug 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants
You can’t perform that action at this time.