Escape all occurrences not only the first

This commit is contained in:
Unrud 2020-04-28 14:11:35 +02:00
parent 1e6c89d11e
commit 8de3a234c4

View File

@ -44,11 +44,11 @@ const COLOR_RE = new RegExp("^(#[0-9A-Fa-f]{6})(?:[0-9A-Fa-f]{2})?$");
*/ */
function escape_xml(s) { function escape_xml(s) {
return (s return (s
.replace("&", "&") .replace(/&/g, "&")
.replace('"', """) .replace(/"/g, """)
.replace("'", "'") .replace(/'/g, "'")
.replace("<", "&lt;") .replace(/</g, "&lt;")
.replace(">", "&gt;")); .replace(/>/g, "&gt;"));
} }
/** /**