This website works better with JavaScript.
Почетна
Преглед
Помоћ
Пријавите Се
jan
/
mustache.js
огледало од
https://github.com/janl/mustache.js
Прати
1
Волим
0
Креирај огранак
0
Код
Дискусије
0
Издања
46
Вики
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…
Откажи
Сачувај