MCPcopy
hub / github.com/github/awesome-copilot / escapeHtml

Function escapeHtml

website/src/scripts/utils.ts:361–372  ·  view source on GitHub ↗
(text: string | string[])

Source from the content-addressed store, hash-verified

359 * Escape HTML to prevent XSS
360 */
361export function escapeHtml(text: string | string[]): string {
362 if (Array.isArray(text)) {
363 return text.map(escapeHtml).join(", ");
364 }
365
366 return text
367 .replace(/&/g, "&")
368 .replace(/</g, "&lt;")
369 .replace(/>/g, "&gt;")
370 .replace(/"/g, "&quot;")
371 .replace(/'/g, "&#39;");
372}
373
374/**
375 * Validate and sanitize URLs to prevent XSS attacks

Callers 15

openCardDetailsModalFunction · 0.90
renderLocalPluginModalFunction · 0.90
highlightMethod · 0.90
openSkillDetailsModalFunction · 0.90
renderInstructionsHtmlFunction · 0.90
openDetailsModalFunction · 0.90
renderAgentsHtmlFunction · 0.90
formatMultilineTextFunction · 0.90
sanitizeToolUrlFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected