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) {
return (s
.replace("&", "&")
.replace('"', """)
.replace("'", "'")
.replace("<", "&lt;")
.replace(">", "&gt;"));
.replace(/&/g, "&amp;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&apos;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;"));
}
/**