From 4228f918d78ba2906194d6672c127ee0ed496ff6 Mon Sep 17 00:00:00 2001 From: My-Responsitories <107370289+My-Responsitories@users.noreply.github.com> Date: Mon, 4 May 2026 11:16:45 +0000 Subject: [PATCH] fix: html numeric character (#1972) --- lib/utils/em.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/utils/em.dart b/lib/utils/em.dart index 40a96dac1..a36094300 100644 --- a/lib/utils/em.dart +++ b/lib/utils/em.dart @@ -1,6 +1,8 @@ abstract final class Em { static final _exp = RegExp('<[^>]*>([^<]*)]*>'); - static final _htmlRegExp = RegExp(r'&(lt|gt|quot|apos|nbsp|amp);'); + static final _htmlRegExp = RegExp( + r'&(lt|gt|quot|apos|nbsp|amp|#x[a-fA-F\d]{2,4});', + ); static String regCate(String origin) { Iterable matches = _exp.allMatches(origin); @@ -29,6 +31,9 @@ abstract final class Em { 'apos' => "'", 'nbsp' => ' ', 'amp' => '&', + var i? when (i.startsWith('#x')) => String.fromCharCode( + int.parse(i.substring(2), radix: 16), + ), _ => m.group(0)!, }, ),