Skip to content

Commit ca71f38

Browse files
committed
feat(safeHtml): add more default tags
1 parent cb327f3 commit ca71f38

File tree

2 files changed

+69
-10
lines changed

2 files changed

+69
-10
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "html5parser",
33
"description": "A fast, accurate AST parser for HTML5",
4-
"version": "1.2.0",
4+
"version": "1.2.1",
55
"author": "acrazing <[email protected]>",
66
"keywords": [
77
"html5",

src/safeHtml.ts

+68-9
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,90 @@ export interface SafeHtmlOptions {
1616

1717
export const safeHtmlDefaultOptions: SafeHtmlOptions = {
1818
allowedTags: [
19+
'a',
20+
'abbr',
21+
'address',
22+
'area',
23+
'article',
24+
'aside',
25+
'b',
26+
'bdi',
27+
'bdo',
28+
'big',
29+
'blockquote',
30+
'br',
31+
'button',
32+
'caption',
33+
'cite',
34+
'code',
35+
'col',
36+
'colgroup',
37+
'data',
38+
'dd',
39+
'del',
40+
'dfn',
1941
'div',
20-
'p',
42+
'dl',
43+
'dt',
44+
'em',
45+
'figcaption',
46+
'figure',
47+
'footer',
2148
'h1',
2249
'h2',
2350
'h3',
2451
'h4',
2552
'h5',
2653
'h6',
27-
'ol',
28-
'ul',
54+
'header',
55+
'hgroup',
56+
'hr',
57+
'i',
58+
'img',
59+
'ins',
60+
'kbd',
2961
'li',
62+
'main',
63+
'map',
64+
'ol',
65+
'p',
66+
'picture',
67+
'pre',
68+
'q',
69+
'rp',
70+
'rt',
71+
'ruby',
72+
's',
73+
'samp',
74+
'section',
75+
'small',
76+
'span',
77+
'strong',
78+
'sub',
79+
'summary',
80+
'sup',
3081
'table',
31-
'thead',
3282
'tbody',
33-
'tr',
34-
'th',
3583
'td',
36-
'span',
37-
'a',
38-
'img',
84+
'tfoot',
85+
'th',
86+
'thead',
87+
'time',
88+
'tr',
89+
'u',
90+
'ul',
91+
'var',
92+
'wbr',
3993
],
4094
allowedAttrs: ['style'],
4195
tagAllowedAttrs: {
4296
a: ['href', 'target'],
4397
img: ['src'],
98+
td: ['rowspan', 'colspan'],
99+
th: ['rowspan', 'colspan'],
100+
time: ['datetime'],
101+
colgroup: ['span'],
102+
col: ['span'],
44103
},
45104
allowedUrl: /^(?:mailto|tel|https?|ftp|[^:]*[^a-z0-9.+-][^:]*):|^[^:]*$/i,
46105
};

0 commit comments

Comments
 (0)