fix: 评论jumpUrl正则转义
This commit is contained in:
@ -506,21 +506,25 @@ InlineSpan buildContent(
|
|||||||
.replaceAll('"', '"')
|
.replaceAll('"', '"')
|
||||||
.replaceAll(''', "'")
|
.replaceAll(''', "'")
|
||||||
.replaceAll(' ', ' ');
|
.replaceAll(' ', ' ');
|
||||||
// print("content.jumpUrl.keys:" + content.jumpUrl.keys.toString());
|
|
||||||
// 构建正则表达式
|
// 构建正则表达式
|
||||||
final List<String> specialTokens = [
|
final List<String> specialTokens = [
|
||||||
...content.emote.keys,
|
...content.emote.keys,
|
||||||
...content.topicsMeta?.keys?.map((e) => '#$e#') ?? [],
|
...content.topicsMeta?.keys?.map((e) => '#$e#') ?? [],
|
||||||
...content.atNameToMid.keys.map((e) => '@$e'),
|
...content.atNameToMid.keys.map((e) => '@$e'),
|
||||||
...content.jumpUrl.keys.map((e) =>
|
|
||||||
e.replaceAll('?', '\\?').replaceAll('+', '\\+').replaceAll('*', '\\*')),
|
|
||||||
];
|
];
|
||||||
|
List<dynamic> jumpUrlKeysList = content.jumpUrl.keys.map((e) {
|
||||||
|
return e.replaceAllMapped(
|
||||||
|
RegExp(r'[?+*]'), (match) => '\\${match.group(0)}');
|
||||||
|
}).toList();
|
||||||
|
|
||||||
String patternStr = specialTokens.map(RegExp.escape).join('|');
|
String patternStr = specialTokens.map(RegExp.escape).join('|');
|
||||||
if (patternStr.isNotEmpty) {
|
if (patternStr.isNotEmpty) {
|
||||||
patternStr += "|";
|
patternStr += "|";
|
||||||
}
|
}
|
||||||
patternStr += r'(\b(?:\d+[::])?[0-5]?[0-9][::][0-5]?[0-9]\b)';
|
patternStr += r'(\b(?:\d+[::])?[0-5]?[0-9][::][0-5]?[0-9]\b)';
|
||||||
|
if (jumpUrlKeysList.isNotEmpty) {
|
||||||
|
patternStr += '|${jumpUrlKeysList.join('|')}';
|
||||||
|
}
|
||||||
final RegExp pattern = RegExp(patternStr);
|
final RegExp pattern = RegExp(patternStr);
|
||||||
List<String> matchedStrs = [];
|
List<String> matchedStrs = [];
|
||||||
void addPlainTextSpan(str) {
|
void addPlainTextSpan(str) {
|
||||||
@ -599,7 +603,6 @@ InlineSpan buildContent(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
print("matchStr=$matchStr");
|
|
||||||
String appUrlSchema = '';
|
String appUrlSchema = '';
|
||||||
final bool enableWordRe = setting.get(SettingBoxKey.enableWordRe,
|
final bool enableWordRe = setting.get(SettingBoxKey.enableWordRe,
|
||||||
defaultValue: false) as bool;
|
defaultValue: false) as bool;
|
||||||
|
|||||||
Reference in New Issue
Block a user