mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-09-14 20:42:04 +09:00
8722057545
There were two: the one in dom_helpers escaped through a text node, which leaves double quotes alone, so it could not have closed the hole in the link preview's img src. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0186eyzivcTn6wqjEE4Wnxdt
14 lines
422 B
JavaScript
14 lines
422 B
JavaScript
const HTML_ESCAPES = { "&": "&", "<": "<", ">": ">", "\"": """, "'": "'" }
|
|
|
|
export function truncateString(string, length, omission = "…") {
|
|
if (string.length <= length) {
|
|
return string
|
|
} else {
|
|
return string.slice(0, length - omission.length) + omission
|
|
}
|
|
}
|
|
|
|
export function escapeHTML(string) {
|
|
return String(string ?? "").replace(/[&<>"']/g, character => HTML_ESCAPES[character])
|
|
}
|