Enable safe inline svg tags in trusted html (#156216)

Enable safe svg tags in trusted html

From cce00ac40d/src/tags.js (L124)
This commit is contained in:
Matt Bierner 2022-07-25 16:32:10 -07:00 committed by GitHub
parent a444059eeb
commit cf145a83ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,57 +8,108 @@ import MarkdownIt from 'markdown-it';
import type * as MarkdownItToken from 'markdown-it/lib/token';
import type { ActivationFunction } from 'vscode-notebook-renderer';
const allowedHtmlTags = Object.freeze([
'a',
'b',
'blockquote',
'br',
'button',
'caption',
'center',
'code',
'col',
'colgroup',
'details',
'div',
'em',
'font',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'hr',
'i',
'img',
'input',
'kbd',
'label',
'li',
'ol',
'p',
'pre',
'select',
'small',
'span',
'strong',
'sub',
'summary',
'sup',
'table',
'tbody',
'td',
'textarea',
'tfoot',
'th',
'thead',
'tr',
'tt',
'u',
'ul',
'video',
]);
const allowedSvgTags = Object.freeze([
'svg',
'a',
'altglyph',
'altglyphdef',
'altglyphitem',
'animatecolor',
'animatemotion',
'animatetransform',
'circle',
'clippath',
'defs',
'desc',
'ellipse',
'filter',
'font',
'g',
'glyph',
'glyphref',
'hkern',
'image',
'line',
'lineargradient',
'marker',
'mask',
'metadata',
'mpath',
'path',
'pattern',
'polygon',
'polyline',
'radialgradient',
'rect',
'stop',
'style',
'switch',
'symbol',
'text',
'textpath',
'title',
'tref',
'tspan',
'view',
'vkern',
]);
const sanitizerOptions: DOMPurify.Config = {
ALLOWED_TAGS: [
'a',
'b',
'blockquote',
'br',
'button',
'caption',
'center',
'code',
'col',
'colgroup',
'details',
'div',
'em',
'font',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'hr',
'i',
'img',
'input',
'kbd',
'label',
'li',
'ol',
'p',
'pre',
'select',
'small',
'span',
'strong',
'sub',
'summary',
'sup',
'table',
'tbody',
'td',
'textarea',
'tfoot',
'th',
'thead',
'tr',
'tt',
'u',
'ul',
'video',
...allowedHtmlTags,
...allowedSvgTags,
],
};