mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 18:52:19 +00:00
fix(queryRegex): safe escape for query regex (#4493)
Co-authored-by: Sambhavi Pandey <sambhavi.pandey@aexp.com>
This commit is contained in:
@@ -39,7 +39,11 @@ export function trimJsonExt(path?: string) {
|
|||||||
|
|
||||||
export function highlightQuery(text: string, query: string) {
|
export function highlightQuery(text: string, query: string) {
|
||||||
if (!query) return text
|
if (!query) return text
|
||||||
const regex = new RegExp(`(${query})`, 'gi')
|
|
||||||
|
// Escape special regex characters in the query string
|
||||||
|
const escapedQuery = query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||||
|
|
||||||
|
const regex = new RegExp(`(${escapedQuery})`, 'gi')
|
||||||
return text.replace(regex, '<span class="highlight">$1</span>')
|
return text.replace(regex, '<span class="highlight">$1</span>')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user