|
@@ -10,7 +10,7 @@ const htmlEntity = { |
|
@@ -10,7 +10,7 @@ const htmlEntity = { |
10
|
};
|
10
|
};
|
11
|
|
11
|
|
12
|
exports.htmlDecode = function(txt) {
|
12
|
exports.htmlDecode = function(txt) {
|
13
|
- txt = txt || '';
|
13
|
+ txt = txt + '' || '';
|
14
|
return txt.replace(/((&(([a-z][a-z0-9]*)|(#[0-9]+)|(#x[0-9a-f]+));)|["'<>&])/gi, function(s) {
|
14
|
return txt.replace(/((&(([a-z][a-z0-9]*)|(#[0-9]+)|(#x[0-9a-f]+));)|["'<>&])/gi, function(s) {
|
15
|
s = s || '';
|
15
|
s = s || '';
|
16
|
const s1 = htmlEntity[s.toLowerCase()];
|
16
|
const s1 = htmlEntity[s.toLowerCase()];
|
|
@@ -24,7 +24,8 @@ exports.htmlDecode = function(txt) { |
|
@@ -24,7 +24,8 @@ exports.htmlDecode = function(txt) { |
24
|
};
|
24
|
};
|
25
|
|
25
|
|
26
|
exports.htmlEncode = function(str) {
|
26
|
exports.htmlEncode = function(str) {
|
27
|
- str = str || '';
|
27
|
+ str = str + '' || '';
|
|
|
28
|
+
|
28
|
return str.replace(re, function(s) {
|
29
|
return str.replace(re, function(s) {
|
29
|
switch (s) {
|
30
|
switch (s) {
|
30
|
case '"':
|
31
|
case '"':
|