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 of unsafe HTML in SVG files #3250

Merged
merged 3 commits into from
Mar 15, 2021

Conversation

peterbe
Copy link
Contributor

@peterbe peterbe commented Mar 15, 2021

Fixes #3249

First of all, I don't know why CI wasn't running on mdn/content#3162
What's up with that?!

Anyway, based on the file in that PR, it does correctly throw:

MOZILLA/MDN/yari  3249-check-of-unsafe-html-in-svg-files ✔
▶ yarn filecheck /Users/peterbe/dev/MOZILLA/MDN/content/files/en-us/mozilla/developer_guide/development_process_overview/workflow.svg
yarn run v1.22.10
$ cd filecheck && node cli.js /Users/peterbe/dev/MOZILLA/MDN/content/files/en-us/mozilla/developer_guide/development_process_overview/workflow.svg
Error: /Users/peterbe/dev/MOZILLA/MDN/content/files/en-us/mozilla/developer_guide/development_process_overview/workflow.svg <svg> contains an unsafe attribute key: 'onload'
    at Node.<anonymous> (/Users/peterbe/dev/MOZILLA/MDN/yari/filecheck/checker.js:73:17)
    at initialize.exports.each (/Users/peterbe/dev/MOZILLA/MDN/yari/node_modules/cheerio/lib/api/traversing.js:562:24)
    at checkFile (/Users/peterbe/dev/MOZILLA/MDN/yari/filecheck/checker.js:66:12)
    at async Promise.all (index 0)
    at async Se.run (/Users/peterbe/dev/MOZILLA/MDN/yari/node_modules/@caporal/core/dist/index.js:1:27579)
    at async Te._run (/Users/peterbe/dev/MOZILLA/MDN/yari/node_modules/@caporal/core/dist/index.js:1:32257)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@peterbe peterbe requested a review from escattone March 15, 2021 21:45
@peterbe
Copy link
Contributor Author

peterbe commented Mar 15, 2021

I also took the liberty of adding a minor test harness of testing all the code inside filechecker/checker.js because apparently we didn't have any.
Ideally, we prefer full end-to-end testing but this is hard to simulate as a CLI since you'd have to use bash or something to invoke the CLI every time. jest feels more useful in this case.

Copy link
Contributor

@escattone escattone left a comment

Choose a reason for hiding this comment

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

@peterbe Looks and works great except that the second test should have been for onhandler.svg

testing/tests/filecheck.test.js Outdated Show resolved Hide resolved
testing/tests/filecheck.test.js Outdated Show resolved Hide resolved
@escattone escattone merged commit 8556a9e into mdn:main Mar 15, 2021
@peterbe peterbe deleted the 3249-check-of-unsafe-html-in-svg-files branch March 15, 2021 23:16
peterbe added a commit to peterbe/yari that referenced this pull request Jun 1, 2021
* Check of unsafe HTML in SVG files

Fixes mdn#3249

* mention in index.html file

* feedbacked
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.

Check of unsafe HTML in SVG files
2 participants