全新出发

This commit is contained in:
cc committed 2026-06-30 00:18:31 +08:00
1 parent b06c117b1e
commit fa4edebed6
463 files changed
+181610 -125

No files matched your search

@@ -0,0 +1,43 @@
export function escapeHtml(value: string): string {
if (!value) return ''
return String(value).replace(/[&<>"']/g, c => {
switch (c) {
case '&': return '&amp;'
case '<': return '&lt;'
case '>': return '&gt;'
case '"': return '&quot;'
case "'": return '&#39;'
default: return c
}
})
}
export function escapeAttribute(value: string): string {
if (!value) return ''
return String(value).replace(/[&<>"'`]/g, c => {
switch (c) {
case '&': return '&amp;'
case '<': return '&lt;'
case '>': return '&gt;'
case '"': return '&quot;'
case "'": return '&#39;'
case '`': return '&#96;'
default: return c
}
})
}
export function renderMultilineText(value: string): string {
return escapeHtml(value).replace(/\r?\n/g, '<br />')
}
export function decodeHtmlEntities(value: string): string {
if (!value) return ''
return String(value)
.replace(/&amp;/g, '&')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
.replace(/&quot;/g, '"')
.replace(/&#39;/g, "'")
.replace(/&#96;/g, '`')
}