Cockatrice/webclient/src/websocket/utils/sanitizeHtml.util.ts
Jeremy Letto 26d7fe2ff0
Webatrice: update deps (#4700)
* save work

* fix reset styling

* fix toast reducer

* update non-react deps

* update react libraries

* remove jquery, use sanitize-html instead

* add missing change

* fix deps and dev deps

* update workflow to target Node 16

* run @mui/codemod to remove @mui/styles

* add default body font size

* update react 17 to 18

* declare enum before use

* add rel attr to links

* fix font sizing issue

* trailing commas

* refactor deep destructuring

Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
2022-11-01 12:41:42 -05:00

17 lines
451 B
TypeScript

import sanitize from 'sanitize-html';
export function sanitizeHtml(msg: string): string {
return sanitize(msg, {
allowedTags: ['br', 'a', 'img', 'center', 'b', 'font'],
allowedAttributes: {
'*': ['href', 'color', 'rel', 'target'],
},
allowedSchemes: ['http', 'https', 'ftp'],
transformTags: {
'a': sanitize.simpleTransform('a', {
target: '_blank',
rel: 'noopener noreferrer',
}),
}
});
}