Explorar el Código

Fixed double escaping

calling escapeHtml(escapeHtml(escapeHtml(escapeHtml('&')))) results in
&
pull/531/head
Silviu Marian hace 10 años
padre
commit
e47231ea26
Se han modificado 1 ficheros con 4 adiciones y 6 borrados
  1. +4
    -6
      mustache.js

+ 4
- 6
mustache.js Ver fichero

@@ -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*/;


Cargando…
Cancelar
Guardar