Bläddra i källkod

don't doublt encode entities. Closes #19. Patch by Leeoniya

tags/0.3.0
Jan Lehnardt 16 år sedan
förälder
incheckning
8df3bef014
4 ändrade filer med 6 tillägg och 3 borttagningar
  1. +2
    -1
      examples/escaped.html
  2. +2
    -1
      examples/escaped.js
  3. +1
    -0
      examples/escaped.txt
  4. +1
    -1
      mustache.js

+ 2
- 1
examples/escaped.html Visa fil

@@ -1 +1,2 @@
<h1>{{title}}</h1>
<h1>{{title}}</h1>
But not {{entities}}.

+ 2
- 1
examples/escaped.js Visa fil

@@ -1,5 +1,6 @@
var escaped = {
title: function() {
return "Bear > Shark";
}
},
entities: "&quot;"
};

+ 1
- 0
examples/escaped.txt Visa fil

@@ -1 +1,2 @@
<h1>Bear &gt; Shark</h1>
But not &quot;.

+ 1
- 1
mustache.js Visa fil

@@ -208,7 +208,7 @@ var Mustache = function() {
Does away with nasty characters
*/
escape: function(s) {
return ((s == null) ? "" : s).toString().replace(/[&"<>\\]/g, function(s) {
return ((s == null) ? "" : s).toString().replace(/&(?!\w+;)|["<>\\]/g, function(s) {
switch(s) {
case "&": return "&amp;";
case "\\": return "\\\\";;


Laddar…
Avbryt
Spara