mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-09-14 12:32:04 +09:00
Keep one escapeHTML, and make it safe in an attribute
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
This commit is contained in:
committed by
Rosa Gutierrez
parent
e6022a52c3
commit
8722057545
@@ -1,7 +1,7 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
import FileUploader from "models/file_uploader"
|
||||
import { onNextEventLoopTick, nextFrame } from "helpers/timing_helpers"
|
||||
import { escapeHTML } from "helpers/dom_helpers"
|
||||
import { escapeHTML } from "helpers/string_helpers"
|
||||
|
||||
export default class extends Controller {
|
||||
static classes = ["toolbar"]
|
||||
|
||||
@@ -4,12 +4,6 @@ export function scrollToBottom(container) {
|
||||
container.scrollTop = container.scrollHeight
|
||||
}
|
||||
|
||||
export function escapeHTML(html) {
|
||||
const div = document.createElement("div")
|
||||
div.textContent = html
|
||||
return div.innerHTML
|
||||
}
|
||||
|
||||
export function parseHTMLFragment(html) {
|
||||
const template = document.createElement("template")
|
||||
template.innerHTML = html
|
||||
|
||||
@@ -9,5 +9,5 @@ export function truncateString(string, length, omission = "…") {
|
||||
}
|
||||
|
||||
export function escapeHTML(string) {
|
||||
return String(string).replace(/[&<>"']/g, character => HTML_ESCAPES[character])
|
||||
return String(string ?? "").replace(/[&<>"']/g, character => HTML_ESCAPES[character])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user