TF-3349 Escape messages when forward and reply email
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import 'package:core/presentation/extensions/html_extension.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('HtmlNullableExtension::', () {
|
||||
test('escapeHtmlString should escapes HTML containing onclick attribute', () {
|
||||
String? input = "<a onclick=\"alert('hi')\">Click</a>";
|
||||
expect(input.escapeHtmlString(),
|
||||
'<a onclick="alert('hi')">Click</a>');
|
||||
});
|
||||
|
||||
test('escapeHtmlString should escapes HTML containing multiple events', () {
|
||||
String? input = "<div onmouseover=\"alert('hover')\" onclick=\"doSomething()\">Hover</div>";
|
||||
expect(input.escapeHtmlString(),
|
||||
'<div onmouseover="alert('hover')" onclick="doSomething()">Hover</div>');
|
||||
});
|
||||
|
||||
test('escapeLtGtHtmlString should escapes only < and > with events', () {
|
||||
String? input = "<button onclick=\"run()\">Run</button>";
|
||||
expect(input.escapeLtGtHtmlString(),
|
||||
'<button onclick=\"run()\">Run</button>');
|
||||
});
|
||||
|
||||
test('escapeHtmlString should handles HTML with empty event attributes', () {
|
||||
String? input = "<img src=\"image.png\" onerror=\"\">";
|
||||
expect(input.escapeHtmlString(),
|
||||
'<img src="image.png" onerror="">');
|
||||
});
|
||||
|
||||
test('escapeHtmlString should handles HTML with invalid syntax in events', () {
|
||||
String? input = "<a onclick=\"alert('unclosed event)>Click</a>";
|
||||
expect(input.escapeHtmlString(),
|
||||
'<a onclick="alert('unclosed event)>Click</a>');
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user