3
4
5function xmlescape(text){
6 text = text.replace(/\&/g, "&"); 7 text = text.replace(/</g, "<");
8 text = text.replace(/>/g, ">");
9 text = text.replace(/'/g, "'");
Escaping non-special characters in strings, template literals, and regular expressions doesn't have any effect.
"\'";
'\"';
"\#";
"\e";
`\"`;
`\"${foo}\"`;
`\#{foo}`;
/\!/;
/\@/;
"\"";
'\'';
"\x12";
"\u00a9";
"\371";
"xs\u2111";
`\``;
`\${${foo}}`;
`$\{${foo}}`;
/\/g;
/\t/g;
/\w\$\*\^\./;