Browse Source

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

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

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

14
src/core/func/alias.js

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

Loading…
Cancel
Save