Selaa lähdekoodia

Strict escaping of ampersands

tags/0.5.2
Michael Jackson 14 vuotta sitten
vanhempi
commit
b8a14eafe9
4 muutettua tiedostoa jossa 5 lisäystä ja 5 poistoa
  1. +1
    -1
      mustache.js
  2. +2
    -2
      test/_files/dot_notation.mustache
  3. +1
    -1
      test/_files/escaped.mustache
  4. +1
    -1
      test/_files/escaped.txt

+ 1
- 1
mustache.js Näytä tiedosto

@@ -63,7 +63,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
};

function escapeHtml(string) {
return String(string).replace(/&(?!\w+;)|[<>"']/g, function (s) {
return String(string).replace(/[&<>"']/g, function (s) {
return entityMap[s];
});
}


+ 2
- 2
test/_files/dot_notation.mustache Näytä tiedosto

@@ -1,8 +1,8 @@
<!-- exciting part -->
<h1>{{name}}</h1>
<p>Authors: <ul>{{#authors}}<li>{{.}}</li>{{/authors}}</ul></p>
<p>Price: {{price.currency.symbol}}{{price.value}} {{#price.currency}}{{name}} <b>{{availability.text}}</b>{{/price.currency}}</p>
<p>VAT: {{price.currency.symbol}}{{#price}}{{vat}}{{/price}}</p>
<p>Price: {{{price.currency.symbol}}}{{price.value}} {{#price.currency}}{{name}} <b>{{availability.text}}</b>{{/price.currency}}</p>
<p>VAT: {{{price.currency.symbol}}}{{#price}}{{vat}}{{/price}}</p>
<!-- boring part -->
<h2>Test truthy false values:</h2>
<p>Zero: {{truthy.zero}}</p>


+ 1
- 1
test/_files/escaped.mustache Näytä tiedosto

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

+ 1
- 1
test/_files/escaped.txt Näytä tiedosto

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

Loading…
Peruuta
Tallenna