commonmark / commonmark/commonmark.js
Improve sanitization options: making it pluggable
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.6k
- Forks
- 231
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 3
Description
I would like to have more sanitization options for raw html in markdown. For example: i would like to allow raw html bits like <table>, <tr> and </table> but disallow evil things like <script>takeOverTheWorld();</script>. Right now: we can either allow or disallow all raw html. If we make the sanitation pluggable, the user can choose which sanitation library he/she wants to plug in.
The most straightforward way to make sensitization pluggable would be to provide a function that does what 'potentiallyUnsafe' in lib/html.js does, plus a sanitizeRawHtml function that could be used for HtmlInline and HtmlBlock instead of just always omitting a comment '<!-- raw HTML omitted -->'.
This would be a minimum modification from what we have. I will create a pull request for this.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read lib/html.js, especially potentiallyUnsafe, and trace how HtmlInline and HtmlBlock currently handle raw HTML. Define the sanitizer hook and replacement behavior described in the issue, then verify that safe tags such as table, tr, and /table can be retained while script content is rejected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- content, security
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100