escape html for external strings
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
|||||||
isFileExcalidraw,
|
isFileExcalidraw,
|
||||||
warnDebug,
|
warnDebug,
|
||||||
} from './utils'
|
} from './utils'
|
||||||
|
import { escapeHTML } from './text-processing'
|
||||||
|
|
||||||
export interface IconPacks {
|
export interface IconPacks {
|
||||||
prefixToIconPack: { [prefix: string]: string }
|
prefixToIconPack: { [prefix: string]: string }
|
||||||
@@ -133,7 +134,7 @@ export async function loadIconSVG(
|
|||||||
|
|
||||||
if (!prefix) {
|
if (!prefix) {
|
||||||
// No prefix, assume it's an emoji or text
|
// No prefix, assume it's an emoji or text
|
||||||
return `<span class="omnisearch-result__icon--emoji">${name}</span>`
|
return `<span class="omnisearch-result__icon--emoji">${escapeHTML(name)}</span>`
|
||||||
}
|
}
|
||||||
|
|
||||||
const iconPackName = prefixToIconPack[prefix]
|
const iconPackName = prefixToIconPack[prefix]
|
||||||
|
|||||||
@@ -78,15 +78,6 @@ export class TextProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
escapeHTML(html: string): string {
|
|
||||||
return html
|
|
||||||
.replaceAll('&', '&')
|
|
||||||
.replaceAll('<', '<')
|
|
||||||
.replaceAll('>', '>')
|
|
||||||
.replaceAll('"', '"')
|
|
||||||
.replaceAll("'", ''')
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a list of strings to a list of words, using the \b word boundary.
|
* Converts a list of strings to a list of words, using the \b word boundary.
|
||||||
* Used to find excerpts in a note body, or select which words to highlight.
|
* Used to find excerpts in a note body, or select which words to highlight.
|
||||||
@@ -200,7 +191,7 @@ export class TextProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function escapeHTML(html: string): string {
|
export function escapeHTML(html: string): string {
|
||||||
return html
|
return html
|
||||||
.replaceAll('&', '&')
|
.replaceAll('&', '&')
|
||||||
.replaceAll('<', '<')
|
.replaceAll('<', '<')
|
||||||
|
|||||||
Reference in New Issue
Block a user