From c04a9a5eeae7e23778960ee03349ab53d68e123d Mon Sep 17 00:00:00 2001 From: orz12 Date: Thu, 11 Jul 2024 17:54:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AF=84=E8=AE=BA=E5=8C=BA=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E8=AF=8D=E6=AD=A3=E5=88=99=E7=AC=A6=E5=8F=B7=E6=9C=AA?= =?UTF-8?q?=E8=BD=AC=E4=B9=89=E5=AF=BC=E8=87=B4=E5=8C=B9=E9=85=8D=E8=AF=8D?= =?UTF-8?q?=E6=96=AD=E5=BC=80=EF=BC=88=E5=A6=82A|an=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../video/detail/reply/widgets/reply_item.dart | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index 76031750..1e3af823 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -571,7 +571,7 @@ InlineSpan buildContent( ...content.topicsMeta?.keys?.map((e) => '#$e#') ?? [], ...content.atNameToMid.keys.map((e) => '@$e'), ]; - List jumpUrlKeysList = content.jumpUrl.keys.map((e) { + List jumpUrlKeysList = content.jumpUrl.keys.map((String e) { return e.replaceAllMapped( RegExp(r'[?+*]'), (match) => '\\${match.group(0)}'); }).toList(); @@ -582,7 +582,7 @@ InlineSpan buildContent( } patternStr += r'(\b(?:\d+[::])?[0-5]?[0-9][::][0-5]?[0-9]\b)'; if (jumpUrlKeysList.isNotEmpty) { - patternStr += '|${jumpUrlKeysList.join('|')}'; + patternStr += '|${jumpUrlKeysList.map(RegExp.escape).join('|')}'; } final RegExp pattern = RegExp(patternStr); List matchedStrs = []; @@ -703,7 +703,8 @@ InlineSpan buildContent( title, '', ); - } else if (RegExp(r'^[Cc][Vv][0-9]+$').hasMatch(matchStr)) { + } else if (RegExp(r'^[Cc][Vv][0-9]+$') + .hasMatch(matchStr)) { Get.toNamed('/htmlRender', parameters: { 'url': 'https://www.bilibili.com/read/$matchStr', 'title': title, @@ -792,9 +793,9 @@ InlineSpan buildContent( ); // 只显示一次 matchedStrs.add(matchStr); - } else if (content - .topicsMeta[matchStr.substring(1, matchStr.length - 1)] != - null) { + } else if (matchStr.length > 1 && + content.topicsMeta[matchStr.substring(1, matchStr.length - 1)] != + null) { spanChildren.add( TextSpan( text: matchStr,