diff --git a/src/screens/reader/utils/sanitizeChapterText.ts b/src/screens/reader/utils/sanitizeChapterText.ts index 343ccc76..47e49b65 100644 --- a/src/screens/reader/utils/sanitizeChapterText.ts +++ b/src/screens/reader/utils/sanitizeChapterText.ts @@ -9,33 +9,65 @@ export const sanitizeChapterText = ( ): string => { const text = sanitizeHtml(html, { allowedTags: sanitizeHtml.defaults.allowedTags.concat([ + 'html', + 'head', + 'body', + 'link', + 'style', + 'meta', + 'del', + 'ins', 'img', - 'i', - 'em', - 'b', - 'a', - 'div', - 'ol', - 'li', + 'audio', + 'video', + 'source', + 'object', + 'svg', + 'math', 'title', 'details', 'summary', 'ref', ]), allowedAttributes: { - '*': ['data-*'], - a: ['href', 'class', 'id'], - div: ['class', 'id'], - img: ['src', 'class', 'id'], + '*': [ + 'data-*', + 'class', + 'id', + 'lang', + 'dir', + 'title', + 'epub:type', + 'role', + 'aria-label', + 'aria-labelledby', + 'aria-describedby', + ], + a: ['href', 'name', 'target'], + img: ['src', 'srcset', 'alt', 'width', 'height', 'loading'], ol: ['reversed', 'start', 'type'], - p: ['class', 'id'], - span: ['class', 'id'], - ref: ['href', 'class', 'id'], + ul: ['type'], + li: ['value'], + p: ['align'], + ref: ['href'], + blockquote: ['cite'], + table: ['border', 'cellpadding', 'cellspacing', 'width', 'summary'], + td: ['colspan', 'rowspan', 'align', 'valign'], + th: ['colspan', 'rowspan', 'align', 'valign', 'scope'], + audio: ['src', 'controls'], + video: ['src', 'controls', 'width', 'height'], + source: ['src', 'type', 'srcset'], + svg: ['width', 'height', 'viewBox', 'xmlns'], + q: ['cite'], + time: ['datetime'], + del: ['cite', 'datetime'], + ins: ['cite', 'datetime'], + link: ['rel', 'type', 'href', 'media'], + meta: ['charset', 'name', 'content', 'http-equiv'], }, allowedSchemes: ['data', 'http', 'https', 'file'], }); - // Return the sanitized and updated HTML or an error message return ( text || getString('readerScreen.emptyChapterMessage', {