escape html for content search

This commit is contained in:
Ruben Fiszel
2024-07-06 00:41:35 +02:00
parent e6e08108a6
commit 6844ed9c6d
@@ -64,6 +64,16 @@
function getCounts(n: number) {
return ` (${n})`
}
function escape(htmlStr) {
return htmlStr
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;')
}
$: counts =
search == '' ||
!scripts ||
@@ -126,7 +136,7 @@
filter={search}
items={apps}
f={(s) => {
return YAML.stringify(s.value, null, 4)
return escape(YAML.stringify(s.value, null, 4))
}}
bind:filteredItems={filteredAppItems}
/>