This website works better with JavaScript.
首頁
探索
說明
登入
jan
/
mustache.js
镜像来自
https://github.com/janl/mustache.js
關註
1
收藏
0
複製
0
程式碼
問題管理
0
版本發佈
46
Wiki
Activity
瀏覽代碼
Merge pull request
#530
from janl/improve-html-escaping
Improve HTML escaping
tags/v2.2.1
David da Silva
10 年之前
父節點
53b1c955f9
378bcca8a5
當前提交
34ebd1cb1a
共有
3 個文件被更改
,包括
6 次插入
和
4 次删除
分割檢視
Diff Options
Show Stats
Download Patch File
Download Diff File
+4
-2
mustache.js
+1
-1
test/_files/escaped.js
+1
-1
test/_files/escaped.txt
+ 4
- 2
mustache.js
查看文件
@@ -63,11 +63,13 @@
'>': '>',
'"': '"',
"'": ''',
'/': '/'
'/': '/',
'`': '`',
'=': '='
};
function escapeHtml (string) {
return String(string).replace(/[&<>"'\/]/g, function fromEntityMap (s) {
return String(string).replace(/[&<>"'
`=
\/]/g, function fromEntityMap (s) {
return entityMap[s];
});
}
+ 1
- 1
test/_files/escaped.js
查看文件
@@ -2,5 +2,5 @@
title: function () {
return "Bear > Shark";
},
entities: "" \"'<>/"
entities: "" \"'<>
`=
/"
})
+ 1
- 1
test/_files/escaped.txt
查看文件
@@ -1,2 +1,2 @@
<h1>Bear > Shark</h1>
And even &quot; "'<>/, but not " "'<>/.
And even &quot; "'<>&#x
60;=&#x
2F;, but not " "'<>
`=
/.
Write
Preview
Loading…
取消
儲存