Преглед изворни кода

Merge pull request #199 from cweider/strict-escape-2

Strict escape II
tags/0.5.2
Michael Jackson пре 14 година
родитељ
комит
677489b25f
5 измењених фајлова са 9 додато и 8 уклоњено
  1. +3
    -2
      mustache.js
  2. +2
    -2
      spec/_files/dot_notation.js
  3. +2
    -2
      spec/_files/dot_notation.txt
  4. +1
    -1
      spec/_files/escaped.js
  5. +1
    -1
      spec/_files/escaped.txt

+ 3
- 2
mustache.js Прегледај датотеку

@@ -86,11 +86,12 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
"<": "&lt;", "<": "&lt;",
">": "&gt;", ">": "&gt;",
'"': '&quot;', '"': '&quot;',
"'": '&#39;'
"'": '&#39;',
"/": '&#x2F;'
}; };


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


+ 2
- 2
spec/_files/dot_notation.js Прегледај датотеку

@@ -7,8 +7,8 @@ var dot_notation = {
return this.value * 0.2; return this.value * 0.2;
}, },
currency: { currency: {
symbol: '&euro;',
name: 'Euro'
symbol: '$',
name: 'USD'
} }
}, },
availability:{ availability:{


+ 2
- 2
spec/_files/dot_notation.txt Прегледај датотеку

@@ -1,8 +1,8 @@
<!-- exciting part --> <!-- exciting part -->
<h1>A Book</h1> <h1>A Book</h1>
<p>Authors: <ul><li>John Power</li><li>Jamie Walsh</li></ul></p> <p>Authors: <ul><li>John Power</li><li>Jamie Walsh</li></ul></p>
<p>Price: &euro;200 Euro <b>In Stock</b></p>
<p>VAT: &euro;40</p>
<p>Price: $200 USD <b>In Stock</b></p>
<p>VAT: $40</p>
<!-- boring part --> <!-- boring part -->
<h2>Test truthy false values:</h2> <h2>Test truthy false values:</h2>
<p>Zero: 0</p> <p>Zero: 0</p>


+ 1
- 1
spec/_files/escaped.js Прегледај датотеку

@@ -2,5 +2,5 @@ var escaped = {
title: function() { title: function() {
return "Bear > Shark"; return "Bear > Shark";
}, },
entities: "&quot;"
entities: "&quot; \"'<>/"
}; };

+ 1
- 1
spec/_files/escaped.txt Прегледај датотеку

@@ -1,2 +1,2 @@
<h1>Bear &gt; Shark</h1> <h1>Bear &gt; Shark</h1>
But not &quot;.
But not &amp;quot; &quot;&#39;&lt;&gt;&#x2F;.

Loading…
Откажи
Сачувај