mod: 搜索专栏副标题转义

This commit is contained in:
guozhigq
2024-03-27 23:34:59 +08:00
parent 463ee1d5b5
commit 6b028c36af
2 changed files with 16 additions and 11 deletions

View File

@ -19,16 +19,7 @@ class Em {
return regCate(matchStr);
}, onNonMatch: (String str) {
if (str != '') {
str = str
.replaceAll('&lt;', '<')
.replaceAll('&gt;', '>')
.replaceAll('&#34;', '"')
.replaceAll('&#39;', "'")
.replaceAll('&quot;', '"')
.replaceAll('&apos;', "'")
.replaceAll('&nbsp;', " ")
.replaceAll('&amp;', "&")
.replaceAll('&#x27;', "'");
str = decodeHtmlEntities(str);
Map map = {'type': 'text', 'text': str};
res.add(map);
}
@ -36,4 +27,17 @@ class Em {
});
return res;
}
static String decodeHtmlEntities(String title) {
return title
.replaceAll('&lt;', '<')
.replaceAll('&gt;', '>')
.replaceAll('&#34;', '"')
.replaceAll('&#39;', "'")
.replaceAll('&quot;', '"')
.replaceAll('&apos;', "'")
.replaceAll('&nbsp;', " ")
.replaceAll('&amp;', "&")
.replaceAll('&#x27;', "'");
}
}