TF-3691 Support HTML escaping in search snippets

Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
dab246
2025-04-24 02:33:23 +07:00
committed by Dat H. Pham
parent a8fbc3f9a7
commit ac569387d4
8 changed files with 168 additions and 4 deletions
+19
View File
@@ -1,6 +1,8 @@
import 'dart:convert';
import 'dart:math';
import 'package:html_unescape/html_unescape.dart';
import 'js_interop_stub.dart' if (dart.library.html) 'dart:js_interop';
import 'dart:typed_data';
@@ -13,6 +15,7 @@ import 'package:universal_html/html.dart' as html;
class HtmlUtils {
static final random = Random();
static final htmlUnescape = HtmlUnescape();
static const lineHeight100Percent = (
script: '''
@@ -530,4 +533,20 @@ class HtmlUtils {
logError('AppUtils::setWindowBrowserTitle:Exception = $e');
}
}
static String unescapeHtml(String input) {
try {
return htmlUnescape.convert(input);
} catch (e) {
logError('HtmlUtils::unescapeHtml:Exception = $e');
return input;
}
}
static String removeWhitespace(String input) {
return input
.replaceAll('\r', '')
.replaceAll('\n', '')
.replaceAll('\t', '');
}
}