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

Check only stylesheet link rels rather than whitelisting other rels #529

Merged
merged 3 commits into from
Sep 7, 2019

Conversation

Floppy
Copy link
Contributor

@Floppy Floppy commented Aug 12, 2019

This is the alternative solution for the addition in #528. The SRI spec only applies to <link rel='stylesheet'>, so this PR only applies the check to those. This means we don't need an ever-expanding whitelist of rel types, but can easily add more into the check.

@codecov-io
Copy link

codecov-io commented Aug 12, 2019

Codecov Report

Merging #529 into master will increase coverage by 0.14%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #529      +/-   ##
==========================================
+ Coverage   98.38%   98.53%   +0.14%     
==========================================
  Files          30       30              
  Lines        1924     1979      +55     
==========================================
+ Hits         1893     1950      +57     
+ Misses         31       29       -2
Impacted Files Coverage Δ
spec/html-proofer/links_spec.rb 99.27% <100%> (ø) ⬆️
lib/html-proofer/check/links.rb 98.79% <100%> (ø) ⬆️
lib/html-proofer/cache.rb 96.45% <0%> (+4.23%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4ad140e...b345cdc. Read the comment docs.


def check_sri(line, content)
return if IGNORABE_REL.include?(@link.rel)
return unless SRI_REL_TYPES.include?(@link.rel)
Copy link
Owner

Choose a reason for hiding this comment

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

I like this but I think I have to think on it a bit more before approving. For example, script and link will also need to be checked. I'm not sure if there are more.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, this code should only apply to link tags - script is handled by another check, in https://github.com/gjtorikian/html-proofer/blob/master/lib/html-proofer/check/scripts.rb#L33, so is unaffected. As I mentioned, as far as I can tell from the spec, the only thing that is proactively loaded in by browsers from link tags are rel='stylesheet', which this should cover.

Copy link
Owner

Choose a reason for hiding this comment

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

You're right! My mistake.

Copy link
Collaborator

@fulldecent fulldecent left a comment

Choose a reason for hiding this comment

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

💯 looks good to me

@fulldecent
Copy link
Collaborator

@gjtorikian Does this additional documentation resolve the issue? 277e1c9

@gjtorikian
Copy link
Owner

Thanks y'all!

@gjtorikian gjtorikian merged commit e9b4abb into master Sep 7, 2019
@gjtorikian gjtorikian deleted the blacklist-stylesheet-links branch September 7, 2019 11:28
This pull request was closed.
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.

4 participants