Este sitio web funciona mejor con JavaScript.
Inicio
Explorar
Ayuda
Iniciar sesión
jan
/
mustache.js
réplica de
https://github.com/janl/mustache.js
Seguir
1
Destacar
0
Fork
0
Código
Incidencias
0
Lanzamientos
46
Wiki
Actividad
Explorar el Código
Merge pull request
#530
from janl/improve-html-escaping
Improve HTML escaping
tags/v2.2.1
David da Silva
hace 10 años
padre
53b1c955f9
378bcca8a5
commit
34ebd1cb1a
Se han
modificado 3 ficheros
con
6 adiciones
y
4 borrados
Dividir vista
Opciones de diferencias
Mostrar estadísticas
Descargar archivo de parche
Descargar archivo de diferencias
+4
-2
mustache.js
+1
-1
test/_files/escaped.js
+1
-1
test/_files/escaped.txt
+ 4
- 2
mustache.js
Ver fichero
@@ -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
Ver fichero
@@ -2,5 +2,5 @@
title: function () {
return "Bear > Shark";
},
entities: "" \"'<>/"
entities: "" \"'<>
`=
/"
})
+ 1
- 1
test/_files/escaped.txt
Ver fichero
@@ -1,2 +1,2 @@
<h1>Bear > Shark</h1>
And even &quot; "'<>/, but not " "'<>/.
And even &quot; "'<>&#x
60;=&#x
2F;, but not " "'<>
`=
/.
Escribir
Vista previa
Cargando…
Cancelar
Guardar