Fixed missing escaping of HTML in search highlighting

This commit is contained in:
squidfunk
2021-07-28 21:57:09 +02:00
parent fc9cfaa263
commit 6744eb6070
6 changed files with 5 additions and 94 deletions

View File

@@ -20,6 +20,8 @@
* IN THE SOFTWARE.
*/
import escapeHTML from "escape-html"
import { SearchIndexConfig } from "../_"
/* ----------------------------------------------------------------------------
@@ -77,7 +79,7 @@ export function setupSearchHighlighter(
})`, "img")
/* Highlight string value */
return value => value
return value => escapeHTML(value)
.replace(match, highlight)
.replace(/<\/mark>(\s+)<mark[^>]*>/img, "$1")
}