Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

refactor(mcp-host): escape dashboard attributes with the one HTML escaper

marcoteb3add0605c5e4
diff --git a/mcp-host/src/workflow/dashboardHtml.ts b/mcp-host/src/workflow/dashboardHtml.ts
index 2f400801f..f07f5b138 100644
--- a/mcp-host/src/workflow/dashboardHtml.ts
+++ b/mcp-host/src/workflow/dashboardHtml.ts
@@ -4,7 +4,7 @@
* opened straight from disk in the user's browser.
*/
-/** Escape text for an element body or a quoted attribute. */
+/** Escape text for an element body or an attribute, single or double quoted. */
export function escapeHtml(s: unknown): string {
return String(s ?? '')
.replace(/&/g, '&')
@@ -36,16 +36,5 @@ export function safeJsonForScript(v: unknown): string {
.replace(/\u2029/g, '\\u2029')
}
-/**
- * Escape a value for use inside an HTML attribute (single OR double
- * quoted). Defends against attribute-breakout XSS like
- * `data-foo='${val}'` where `val` contains `'`.
- */
-export function escapeHtmlAttr(s: unknown): string {
- return String(s ?? '')
- .replace(/&/g, '&')
- .replace(/"/g, '"')
- .replace(/'/g, ''')
- .replace(/</g, '&lt;')
- .replace(/>/g, '&gt;')
-}
+/** escapeHtml under the name callers of an attribute value use. */
+export const escapeHtmlAttr = escapeHtml