Escape HTML

Instead of trying to do some smart (and unsecure) stuff, just display the raw note contents as is
This commit is contained in:
Simon Cambier
2022-04-15 17:16:37 +02:00
parent 5602b1d8c8
commit e949f0916a
6 changed files with 32 additions and 54 deletions

View File

@@ -1,4 +1,3 @@
import markdownToTxt from 'markdown-to-txt'
import { CachedMetadata } from 'obsidian'
import {
isSearchMatch,
@@ -12,12 +11,13 @@ export function highlighter(str: string): string {
return '<span class="search-result-file-matched-text">' + str + '</span>'
}
/**
* Strips the markdown and frontmatter
* @param text
*/
export function clearContent(text: string): string {
return markdownToTxt(removeFrontMatter(text))
export function escapeHTML(html: string): string {
return html
.replaceAll('&', '&amp;')
.replaceAll('<', '&lt;')
.replaceAll('>', '&gt;')
.replaceAll('"', '&quot;')
.replaceAll("'", '&#039;')
}
/**