diff --git a/src/services/html_sanitizer.ts b/src/services/html_sanitizer.ts
index 9a66c6ede..acfa75434 100644
--- a/src/services/html_sanitizer.ts
+++ b/src/services/html_sanitizer.ts
@@ -1,5 +1,6 @@
import sanitizeHtml from "sanitize-html";
import sanitizeUrl from "@braintree/sanitize-url";
+import optionService from "./options.js";
// intended mainly as protection against XSS via import
// secondarily, it (partly) protects against "CSS takeover"
@@ -23,9 +24,13 @@ function sanitize(dirtyHtml: string) {
}
}
- // to minimize document changes, compress H
- return sanitizeHtml(dirtyHtml, {
- allowedTags: [
+ // Get allowed tags from options, with fallback to default list if option not yet set
+ let allowedTags;
+ try {
+ allowedTags = JSON.parse(optionService.getOption('allowedHtmlTags'));
+ } catch (e) {
+ // Fallback to default list if option doesn't exist or is invalid
+ allowedTags = [
'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'p', 'a', 'ul', 'ol',
'li', 'b', 'i', 'strong', 'em', 'strike', 's', 'del', 'abbr', 'code', 'hr', 'br', 'div',
'table', 'thead', 'caption', 'tbody', 'tfoot', 'tr', 'th', 'td', 'pre', 'section', 'img',
@@ -37,7 +42,12 @@ function sanitize(dirtyHtml: string) {
'acronym', 'article', 'big', 'button', 'cite', 'col', 'colgroup', 'data', 'dd',
'fieldset', 'form', 'legend', 'meter', 'noscript', 'option', 'progress', 'rp',
'samp', 'small', 'sub', 'sup', 'template', 'textarea', 'tt'
- ],
+ ];
+ }
+
+ // to minimize document changes, compress H
+ return sanitizeHtml(dirtyHtml, {
+ allowedTags,
allowedAttributes: {
'*': [ 'class', 'style', 'title', 'src', 'href', 'hash', 'disabled', 'align', 'alt', 'center', 'data-*' ]
},
diff --git a/src/services/options_init.ts b/src/services/options_init.ts
index 1dc7602d2..f83608213 100644
--- a/src/services/options_init.ts
+++ b/src/services/options_init.ts
@@ -134,7 +134,21 @@ const defaultOptions: DefaultOption[] = [
{ name: "codeBlockWordWrap", value: "false", isSynced: true },
// Text note configuration
- { name: "textNoteEditorType", value: "ckeditor-balloon", isSynced: true }
+ { name: "textNoteEditorType", value: "ckeditor-balloon", isSynced: true },
+
+ // HTML sanitization configuration
+ { name: "allowedHtmlTags", value: JSON.stringify([
+ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'p', 'a', 'ul', 'ol',
+ 'li', 'b', 'i', 'strong', 'em', 'strike', 's', 'del', 'abbr', 'code', 'hr', 'br', 'div',
+ 'table', 'thead', 'caption', 'tbody', 'tfoot', 'tr', 'th', 'td', 'pre', 'section', 'img',
+ 'figure', 'figcaption', 'span', 'label', 'input', 'details', 'summary', 'address', 'aside', 'footer',
+ 'header', 'hgroup', 'main', 'nav', 'dl', 'dt', 'menu', 'bdi', 'bdo', 'dfn', 'kbd', 'mark', 'q', 'time',
+ 'var', 'wbr', 'area', 'map', 'track', 'video', 'audio', 'picture', 'del', 'ins',
+ 'en-media',
+ 'acronym', 'article', 'big', 'button', 'cite', 'col', 'colgroup', 'data', 'dd',
+ 'fieldset', 'form', 'legend', 'meter', 'noscript', 'option', 'progress', 'rp',
+ 'samp', 'small', 'sub', 'sup', 'template', 'textarea', 'tt'
+ ]), isSynced: true }
];
/**