Procházet zdrojové kódy

Fixed double escaping

calling escapeHtml(escapeHtml(escapeHtml(escapeHtml('&')))) results in
&
pull/531/head
Silviu Marian před 10 roky
rodič
revize
e47231ea26
1 změnil soubory, kde provedl 4 přidání a 6 odebrání
  1. +4
    -6
      mustache.js

+ 4
- 6
mustache.js Zobrazit soubor

@@ -58,7 +58,6 @@
}

var entityMap = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
@@ -67,11 +66,10 @@
'`': '&#x60;',
'=': '&#x3D;'
};

function escapeHtml (string) {
return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) {
return entityMap[s];
});
function escapeHtml(string) {
return String(string)
.replace(/[<>"'\/]/g, function (s) { return entityMap[s]; })
.replace(/&(?![A-Za-z0-9#][A-Za-z0-9]+;)+/g, '&amp;');
}

var whiteRe = /\s*/;


Načítá se…
Zrušit
Uložit