commonmark / commonmark/commonmark.js

Improve sanitization options: making it pluggable

Open
#84 0 comments 3 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.