-
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: allow disable sanitization (#564) * test: #564 * chore: add changeset * chore: restore prior whitespace * refactor: adjust sanitizer to provide more data to the composer * refactor: DX tweaks * chore: adjust size limit will golf this down later * chore: tweak changeset --------- Co-authored-by: Evan Jacobs <[email protected]>
- Loading branch information
Showing
5 changed files
with
145 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
'markdown-to-jsx': minor | ||
--- | ||
|
||
Allow modifying HTML attribute sanitization when `options.sanitizer` is passed by the composer. | ||
|
||
By default a lightweight URL sanitizer function is provided to avoid common attack vectors that might be placed into the `href` of an anchor tag, for example. The sanitizer receives the input, the HTML tag being targeted, and the attribute name. The original function is available as a library export called `sanitizer`. | ||
|
||
This can be overridden and replaced with a custom sanitizer if desired via `options.sanitizer`: | ||
|
||
```jsx | ||
// sanitizer in this situation would receive: | ||
// ('javascript:alert("foo")', 'a', 'href') | ||
|
||
;<Markdown options={{ sanitizer: (value, tag, attribute) => value }}> | ||
{`[foo](javascript:alert("foo"))`} | ||
</Markdown> | ||
|
||
// or | ||
|
||
compiler('[foo](javascript:alert("foo"))', { | ||
sanitizer: (value, tag, attribute) => value, | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters