/
GreyCat
/
better-clawd
Обзор
Документация
Войти
/
GreyCat
/
better-clawd
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/utils/xml.ts
16 строк
622 B
x1xhlol
initial commit
01 апр 2026, 15:19
01 апр 2026, 15:19
420d415
Код
Авторство
О чём код?
/** * Escape XML/HTML special characters for safe interpolation into element * text content (between tags). Use when untrusted strings (process stdout, * user input, external data) go inside `<tag>${here}</tag>`. */ export function escapeXml(s: string): string { return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>') } /** * Escape for interpolation into a double- or single-quoted attribute value: * `<tag attr="${here}">`. Escapes quotes in addition to `& < >`. */ export function escapeXmlAttr(s: string): string { return escapeXml(s).replace(/"/g, '"').replace(/'/g, ''') }