Browse Source

Pull request #2550: 无JIRA任务 htmlEncode区分空格和回车

Merge in VISUAL/fineui from ~WINDY/fui:master to master

* commit '499ab6b8b506c14c5648d10f513dad78a7275f49':
  无JIRA任务 htmlEncode区分空格和回车
es6
windy 2 years ago
parent
commit
6b1a0fea48
  1. 14
      src/core/func/alias.js

14
src/core/func/alias.js

@ -417,16 +417,17 @@
"\"": """, "\"": """,
"<": "&lt;", "<": "&lt;",
">": "&gt;", ">": "&gt;",
" ": "&nbsp;" "\x20": "&nbsp;",
"\n": "&#10;"
}; };
BI.htmlEncode = function (text) { BI.htmlEncode = function (text) {
return BI.isNull(text) ? "" : BI.replaceAll(text + "", "&|\"|<|>|\\s", function (v) { return BI.isNull(text) ? "" : BI.replaceAll(text + "", BI.keys(SPECIAL_TAGS).join("|"), function (v) {
return SPECIAL_TAGS[v] ? SPECIAL_TAGS[v] : "&nbsp;"; return SPECIAL_TAGS[v] ? SPECIAL_TAGS[v] : v;
}); });
}; };
// html decode // html decode
BI.htmlDecode = function (text) { BI.htmlDecode = function (text) {
return BI.isNull(text) ? "" : BI.replaceAll(text + "", "&amp;|&quot;|&lt;|&gt;|&nbsp;", function (v) { return BI.isNull(text) ? "" : BI.replaceAll(text + "", BI.values(SPECIAL_TAGS).join("|"), function (v) {
switch (v) { switch (v) {
case "&amp;": case "&amp;":
return "&"; return "&";
@ -437,8 +438,11 @@
case "&gt;": case "&gt;":
return ">"; return ">";
case "&nbsp;": case "&nbsp;":
default:
return " "; return " ";
case "&#10;":
return "\n";
default:
return v;
} }
}); });
}; };

Loading…
Cancel
Save