-
-
Notifications
You must be signed in to change notification settings - Fork 902
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
Follow WHATWG guidance for incorrectly-closed HTML comments #2058
Conversation
Code Climate has analyzed commit 6c1c5fa and detected 0 issues on this pull request. View more on Code Climate. |
ce3c0bd
to
1d0ab01
Compare
✅ Build nokogiri 1.0.620 completed (commit d9014b28e8 by @flavorjones) |
48e4a33
to
b8719a4
Compare
❌ Build nokogiri 1.0.626 failed (commit 039b8d37d3 by @flavorjones) |
b8719a4
to
6c1c5fa
Compare
✅ Build nokogiri 1.0.629 completed (commit 0c6c52393f by @flavorjones) |
Also see related upstream merge request: https://gitlab.gnome.org/GNOME/libxml2/-/merge_requests/82 |
6c1c5fa
to
4f0e359
Compare
this is pre-work related to what I think is an upstream issue in libxml2 regarding parsing comments.
See guidance provided on incorrectly-closed comments here: https://html.spec.whatwg.org/multipage/parsing.html#parse-error-incorrectly-closed-comment
[skip ci]
4f0e359
to
eaa9c73
Compare
…ed-html-comments feat(cruby): patch libxml2 to handle abruptly-closed HTML comments --- **What problem is this PR intended to solve?** Hackerone user [tehryanx](https://hackerone.com/tehryanx?type=user) reported a method of potentially confusing Loofah sanitizers by taking advantage of the difference between how abruptly-closed comments are handled by libxml2 and how they're handled by WHATWG-guidance-compliant modern browsers. WHATWG advises to treat `<!-->` and `<!--->` as empty comments, but libxml2 today treats these as the _start_ of a comment. https://html.spec.whatwg.org/multipage/parsing.html#parse-error-abrupt-closing-of-empty-comment I've submitted this patch upstream at https://gitlab.gnome.org/GNOME/libxml2/-/merge_requests/124 Similar prior art is for incorrectly-closed comments: - #2058 - https://gitlab.gnome.org/GNOME/libxml2/-/merge_requests/82 **Have you included adequate test coverage?** Yes! **Does this change affect the behavior of either the C or the Java implementations?** This is a behavior change to libxml2/CRuby. Note that nekoHTML/JRuby already follow WHATWG guidance and so JRuby behavior is unchanged.
This changeset introduces test coverage for both JRuby and CRuby implementations with respect to handling HTML parse errors within comments.
It then introduces a libxml2 patch to comply with the behavior suggested by the WHATWG "Living Standard" doc with respect to incorrectly-closed comments.
It's important to note that WHATWG's guidance is non-normative, but is what's followed by most popular browsers. Further, the difference in behavior between browsers and server-side sanitization done by a library relying on Nokogiri and libxml2 allows opportunity for XSS attacks (https://owasp.org/www-project-top-ten/OWASP_Top_Ten_2017/Top_10-2017_A7-Cross-Site_Scripting_(XSS)).