fix(mu): email content not displayed due to sanitize html

(cherry picked from commit 2f06e52d81864a62d6e588bb24a6845e20371bf4)
This commit is contained in:
dab246
2025-12-15 14:32:02 +07:00
committed by Dat H. Pham
parent 50671b98ee
commit 6f455cc728
10 changed files with 362 additions and 141 deletions
@@ -16,7 +16,7 @@ class SanitizeHyperLinkTagInHtmlTransformer extends DomTransformer {
Map<String, String>? mapUrlDownloadCID,
}) async {
try {
final elements = document.querySelectorAll('a');
final elements = document.querySelectorAll('a[href]');
if (elements.isEmpty) return;
@@ -3,40 +3,13 @@ import 'package:core/presentation/utils/html_transformer/base/text_transformer.d
import 'package:core/presentation/utils/html_transformer/sanitize_html.dart';
class StandardizeHtmlSanitizingTransformers extends TextTransformer {
static const List<String> mailAllowedHtmlAttributes = [
'style',
'public-asset-id',
'data-filename',
'bgcolor',
'id',
'class',
'data-mimetype',
];
static const List<String> mailAllowedHtmlTags = [
'font',
'u',
'center',
'style',
'body',
'section',
'google-sheets-html-origin',
'colgroup',
'col',
'nav',
'main',
'footer',
'supress_time_adjustment',
];
static final SanitizeHtml _sanitizer = SanitizeHtml();
const StandardizeHtmlSanitizingTransformers();
@override
String process(String text, HtmlEscape htmlEscape) =>
SanitizeHtml().process(
inputHtml: text,
allowAttributes: mailAllowedHtmlAttributes,
allowTags: mailAllowedHtmlTags,
);
String process(String text, HtmlEscape htmlEscape) {
if (text.isEmpty) return '';
return _sanitizer.process(inputHtml: text);
}
}