Skip to content

Commit 13a111c

Browse files
committed
fix: enhance XSS protection by allowing additional attributes for span elements and generic data/aria/style attributes
1 parent fbbfc5e commit 13a111c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

adminforth/spa/src/utils/utils.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,12 @@ export function protectAgainstXSS(value: string) {
237237
],
238238
allowedAttributes: {
239239
'li': [ 'data-list' ],
240-
'img': [ 'src', 'srcset', 'alt', 'title', 'width', 'height', 'loading' ]
241-
}
240+
'img': [ 'src', 'srcset', 'alt', 'title', 'width', 'height', 'loading' ],
241+
// Allow markup on spans (classes & styles), and
242+
// generic data/aria/style attributes on any element. (e.g. for KaTeX-related previews)
243+
'span': [ 'class', 'style' ],
244+
'*': [ 'data-*', 'aria-*', 'style' ]
245+
},
242246
});
243247
}
244248

0 commit comments

Comments
 (0)