You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow modifying HTML attribute sanitization when `options.sanitizer` is passed by the composer.
6
+
7
+
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`.
8
+
9
+
This can be overridden and replaced with a custom sanitizer if desired via `options.sanitizer`:
10
+
11
+
```jsx
12
+
// sanitizer in this situation would receive:
13
+
// ('javascript:alert("foo")', 'a', 'href')
14
+
15
+
;<Markdown options={{ sanitizer: (value, tag, attribute) => value }}>
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`.
442
+
443
+
This can be overridden and replaced with a custom sanitizer if desired via `options.sanitizer`:
444
+
445
+
```jsx
446
+
// sanitizer in this situation would receive:
447
+
// ('javascript:alert("foo")', 'a', 'href')
448
+
449
+
;<Markdown options={{ sanitizer: (value, tag, attribute) => value }}>
450
+
{`[foo](javascript:alert("foo"))`}
451
+
</Markdown>
452
+
453
+
// or
454
+
455
+
compiler('[foo](javascript:alert("foo"))', {
456
+
sanitizer: (value, tag, attribute) => value,
457
+
})
458
+
```
459
+
438
460
#### options.slugify
439
461
440
462
By default, a [lightweight deburring function](https://github.com/probablyup/markdown-to-jsx/blob/bc2f57412332dc670f066320c0f38d0252e0f057/index.js#L261-L275) is used to generate an HTML id from headings. You can override this by passing a function to `options.slugify`. This is helpful when you are using non-alphanumeric characters (e.g. Chinese or Japanese characters) in headings. For example:
0 commit comments