mirror of
https://gitee.com/docsifyjs/docsify.git
synced 2024-11-30 02:58:37 +08:00
fix: Add escapeHtml for search (#1551)
Co-authored-by: Anix <anik220798@gmail.com>
This commit is contained in:
parent
32203b77bf
commit
c24f7f6f0b
@ -178,7 +178,7 @@ export function search(query) {
|
||||
keywords.forEach(keyword => {
|
||||
// From https://github.com/sindresorhus/escape-string-regexp
|
||||
const regEx = new RegExp(
|
||||
ignoreDiacriticalMarks(keyword).replace(
|
||||
escapeHtml(ignoreDiacriticalMarks(keyword)).replace(
|
||||
/[|\\{}()[\]^$+*?.]/g,
|
||||
'\\$&'
|
||||
),
|
||||
@ -187,10 +187,10 @@ export function search(query) {
|
||||
let indexTitle = -1;
|
||||
let indexContent = -1;
|
||||
handlePostTitle = postTitle
|
||||
? ignoreDiacriticalMarks(postTitle)
|
||||
? escapeHtml(ignoreDiacriticalMarks(postTitle))
|
||||
: postTitle;
|
||||
handlePostContent = postContent
|
||||
? ignoreDiacriticalMarks(postContent)
|
||||
? escapeHtml(ignoreDiacriticalMarks(postContent))
|
||||
: postContent;
|
||||
|
||||
indexTitle = postTitle ? handlePostTitle.search(regEx) : -1;
|
||||
|
Loading…
Reference in New Issue
Block a user