Strona działa najlepiej z włączonym JavaScript.
Strona główna
Odkrywaj
Pomoc
Zaloguj się
jan
/
mustache.js
kopia lustrzana
https://github.com/janl/mustache.js
Obserwuj
1
Polub
0
Forkuj
0
Kod
Zgłoszenia
0
Wydania
46
Wiki
Aktywność
Przeglądaj źródła
Merge pull request
#530
from janl/improve-html-escaping
Improve HTML escaping
tags/v2.2.1
David da Silva
10 lat temu
rodzic
53b1c955f9
378bcca8a5
commit
34ebd1cb1a
3 zmienionych plików
z
6 dodań
i
4 usunięć
Widok podzielony
Opcje porównania
Pokaż statystyki
Ściągnij plik aktualizacji
Ściągnij plik porównania
+4
-2
mustache.js
+1
-1
test/_files/escaped.js
+1
-1
test/_files/escaped.txt
+ 4
- 2
mustache.js
Wyświetl plik
@@ -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
Wyświetl plik
@@ -2,5 +2,5 @@
title: function () {
return "Bear > Shark";
},
entities: "" \"'<>/"
entities: "" \"'<>
`=
/"
})
+ 1
- 1
test/_files/escaped.txt
Wyświetl plik
@@ -1,2 +1,2 @@
<h1>Bear > Shark</h1>
And even &quot; "'<>/, but not " "'<>/.
And even &quot; "'<>&#x
60;=&#x
2F;, but not " "'<>
`=
/.
Napisz
Podgląd
Ładowanie…
Anuluj
Zapisz