Skip to content

apply user scripts correctly - #15874

Merged
bors-servo merged 1 commit into
servo:masterfrom
sendilkumarn:user-script
Mar 13, 2017
Merged

bors-servo merged 1 commit into
servo:masterfrom
sendilkumarn:user-script

Conversation

@sendilkumarn

@sendilkumarn sendilkumarn commented Mar 8, 2017 •

Copy link
Copy Markdown
Contributor


This change is Reviewable

@highfive

highfive commented Mar 8, 2017

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @fitzgen: components/script/dom/userscripts.rs
  • @KiChjang: components/script/dom/userscripts.rs

@highfive

highfive commented Mar 8, 2017

Copy link
Copy Markdown

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Mar 8, 2017

@SimonSapin SimonSapin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r? @nox

Comment thread components/script/dom/userscripts.rs Outdated
let mut f = File::open(&file).unwrap();
let mut contents = vec![];
f.read_to_end(&mut contents).unwrap();
let script_text = String::from_utf8(contents).unwrap();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use String::from_utf8_lossy, to replace UTF-8 errors with U+FFFD instead of panicking. This show that Firefox does so for external scripts:

data:text/html,<script src='data:text/html;charset=utf-8,document.write("%2580".charCodeAt(0).toString(16))'></script>
fffd

let mut contents = vec![];
f.read_to_end(&mut contents).unwrap();
let script_text = String::from_utf8(contents).unwrap();
win.upcast::<GlobalScope>().evaluate_js_on_global_with_result(&script_text, rval.handle_mut());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nox, does this line look right? (It doesn’t look particularly wrong to me, I just don’t know.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is ok.

@SimonSapin SimonSapin assigned nox and unassigned SimonSapin Mar 13, 2017
@nox nox added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Mar 13, 2017
replace to utf8_lossy
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Mar 13, 2017
@nox

nox commented Mar 13, 2017

Copy link
Copy Markdown
Contributor

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 5b25cb3 has been approved by nox

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Mar 13, 2017
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 5b25cb3 with merge d70c1e5...

bors-servo pushed a commit that referenced this pull request Mar 13, 2017
apply user scripts correctly

<!-- Please describe your changes on the following line: -->

---
<!-- 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 #15082

<!-- 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/15874)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css, mac-rel-wpt1, mac-rel-wpt2, windows-gnu-dev, windows-msvc-dev
Approved by: nox
Pushing d70c1e5 to master...

@bors-servo
bors-servo merged commit 5b25cb3 into servo:master Mar 13, 2017
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Mar 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

User scripts don't apply correctly in about:blank

5 participants