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

Implemementing context-based MIME type sniffing #8190

Merged
merged 9 commits into from Dec 31, 2015
Merged

Conversation

@jdm
Copy link
Member

jdm commented Oct 25, 2015

This is a rebase of #7842 that also adds a test.
Fixes #4183.

@Yoric, how's this look to you?

Review on Reviewable

@jdm
Copy link
Member Author

jdm commented Oct 25, 2015

r? @glennw for the font-loading changes.

metadata.content_type.as_ref().map(|content_type| {
let mime = &content_type.0;
is_supported_font_type(&mime.0, &mime.1)
}).unwrap_or(false);

This comment has been minimized.

Copy link
@frewsxcv

frewsxcv Oct 25, 2015

Member

map(..).unwrap_or(..) can be simplified to .map_or(..)

Some(MediaType::AudioVideo) => self.audio_video_classifier.classify(data),
None => None
}.unwrap_or(supplied_type.clone())
data: &[u8]) -> Option<(String, String)> {

This comment has been minimized.

Copy link
@eefriedman

eefriedman Oct 25, 2015

Contributor

Is there some reason you're changing this? It will substantially simplify downstream code if we can assume MIME sniffing always returns something (even if it's just application/octet-stream or something).

This comment has been minimized.

Copy link
@jdm

jdm Oct 25, 2015

Author Member

That's a good point; I didn't consider just turning a missing Content-Type and unclassifiable into application/octet-stream.

@bors-servo
Copy link
Contributor

bors-servo commented Oct 26, 2015

The latest upstream changes (presumably #7979) made this pull request unmergeable. Please resolve the merge conflicts.

@glennw
Copy link
Member

glennw commented Nov 8, 2015

@jdm Sorry, I missed this one - is it waiting on my review now, or are other changes required before it is worth looking at it?

@jdm
Copy link
Member Author

jdm commented Nov 9, 2015

I don't think the requested changes have any effect on the stuff you're reviewing.

@glennw
Copy link
Member

glennw commented Nov 12, 2015

@jdm The font load changes look ok to me, apart from the question about the mutex usage.

@jdm jdm force-pushed the jdm:4138 branch from f552b23 to 743117c Nov 12, 2015
@jdm
Copy link
Member Author

jdm commented Nov 12, 2015

r? @eefriedman for the most recent changes.

@highfive highfive assigned eefriedman and unassigned glennw Nov 12, 2015
@jdm jdm removed the S-needs-rebase label Nov 12, 2015
@eefriedman
Copy link
Contributor

eefriedman commented Nov 12, 2015

I'd also like to see a test to make sure that content served as application/xhtml+xml is never sniffed as a font, even if it is one.

@eefriedman
Copy link
Contributor

eefriedman commented Nov 12, 2015

Review status: 0 of 25 files reviewed at latest revision, 6 unresolved discussions, some commit checks failed.


components/gfx/font_cache_task.rs, line 381 [r7] (raw file):
x-font-ttf etc. will become irrelevant once sniffing is on by default; maybe put in a FIXME?


components/net/mime_classifier.rs, line 46 [r7] (raw file):
Option has a cloned() method.


components/net/mime_classifier.rs, line 235 [r7] (raw file):
Extra newline.


components/script/document_loader.rs, line 38 [r7] (raw file):
Space before "|".


Comments from the review on Reviewable.io

@bors-servo
Copy link
Contributor

bors-servo commented Nov 13, 2015

The latest upstream changes (presumably #6935) made this pull request unmergeable. Please resolve the merge conflicts.

@Yoric
Copy link
Contributor

Yoric commented Nov 25, 2015

I realize I never responded. @jdm, yes, this lgtm.

@jdm jdm force-pushed the jdm:4138 branch from d60d4b3 to bda341b Dec 31, 2015
@jdm jdm removed the S-needs-rebase label Dec 31, 2015
@jdm
Copy link
Member Author

jdm commented Dec 31, 2015

@bors-servo
Copy link
Contributor

bors-servo commented Dec 31, 2015

Trying commit bda341b with merge 4092a8d...

bors-servo added a commit that referenced this pull request Dec 31, 2015
Implemementing context-based MIME type sniffing

This is a rebase of #7842 that also adds a test.
Fixes #4183.

@Yoric, how's this look to you?

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8190)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Dec 31, 2015

💔 Test failed - linux-rel

@nox
Copy link
Member

nox commented Dec 31, 2015

Tests with unexpected results:
  ▶ FAIL [expected PASS] /_mozilla/css/octicons_a.html
  └   → /_mozilla/css/octicons_a.html f03141f6c2d6c4dc01770f2eac9356912b711b30
/_mozilla/css/octicons_ref.html f03141f6c2d6c4dc01770f2eac9356912b711b30
Testing f03141f6c2d6c4dc01770f2eac9356912b711b30 != f03141f6c2d6c4dc01770f2eac9356912b711b30

  ▶ FAIL [expected PASS] /_mozilla/css/ol_japanese_iroha_bullet_styles.html
  └   → /_mozilla/css/ol_japanese_iroha_bullet_styles.html ff6a9a084545fcff9b7b3584c2070fb986e5cc7b
/_mozilla/css/ol_japanese_iroha_ref.html ff6a9a084545fcff9b7b3584c2070fb986e5cc7b
Testing ff6a9a084545fcff9b7b3584c2070fb986e5cc7b != ff6a9a084545fcff9b7b3584c2070fb986e5cc7b
Tests with unexpected results:
  ▶ FAIL [expected PASS] /css-variables-1_dev/html/variable-font-face-02.htm
  └   → /css-variables-1_dev/html/variable-font-face-02.htm a79786e29fec1999707ffcdcf135997be11e440e
/css-variables-1_dev/html/reference/variable-font-face-02-ref.htm 6a5386967311195847b410a07bbfc3ecdfe87e22
Testing a79786e29fec1999707ffcdcf135997be11e440e == 6a5386967311195847b410a07bbfc3ecdfe87e22

  ▶ FAIL [expected PASS] /css-variables-1_dev/html/variable-external-font-face-01.htm
  └   → /css-variables-1_dev/html/variable-external-font-face-01.htm a79786e29fec1999707ffcdcf135997be11e440e
/css-variables-1_dev/html/reference/variable-external-font-face-01-ref.htm 6a5386967311195847b410a07bbfc3ecdfe87e22
Testing a79786e29fec1999707ffcdcf135997be11e440e == 6a5386967311195847b410a07bbfc3ecdfe87e22

  ▶ FAIL [expected PASS] /css-variables-1_dev/html/variable-font-face-01.htm
  └   → /css-variables-1_dev/html/variable-font-face-01.htm a79786e29fec1999707ffcdcf135997be11e440e
/css-variables-1_dev/html/reference/variable-font-face-01-ref.htm 6a5386967311195847b410a07bbfc3ecdfe87e22
Testing a79786e29fec1999707ffcdcf135997be11e440e == 6a5386967311195847b410a07bbfc3ecdfe87e22

  ▶ PASS [expected FAIL] /css21_dev/html4/floats-wrap-bfc-002-right-table.htm
…tore the status quo.
@jdm
Copy link
Member Author

jdm commented Dec 31, 2015

There. All tests pass locally for me now.

@nox
Copy link
Member

nox commented Dec 31, 2015

@bors-servo r=eefriedman

@bors-servo
Copy link
Contributor

bors-servo commented Dec 31, 2015

📌 Commit 20668da has been approved by eefriedman

@bors-servo
Copy link
Contributor

bors-servo commented Dec 31, 2015

Testing commit 20668da with merge af1690f...

bors-servo added a commit that referenced this pull request Dec 31, 2015
Implemementing context-based MIME type sniffing

This is a rebase of #7842 that also adds a test.
Fixes #4183.

@Yoric, how's this look to you?

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8190)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Dec 31, 2015

@bors-servo bors-servo merged commit 20668da into servo:master Dec 31, 2015
2 of 3 checks passed
2 of 3 checks passed
code-review/reviewable Review in progress: 0 of 29 files reviewed, 6 unresolved discussions
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
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

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