Fix bug with text for nodes. Add escaping symbols.

This commit is contained in:
Unick Soft
2020-08-19 20:45:26 +02:00
parent f068ee2a32
commit 475f4ea88b
6 changed files with 36 additions and 16 deletions

18
script/utils.js Normal file
View File

@@ -0,0 +1,18 @@
function gEncodeToHTML(str)
{
return str.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&apos;');
}
function gDecodeFromHTML(str)
{
return str.replace(/&apos;/g, "'")
.replace(/&quot;/g, '"')
.replace(/&gt;/g, '>')
.replace(/&lt;/g, '<')
.replace(/&amp;/g, '&');
}