浏览代码

Strict escaping of ampersands

tags/0.5.2
Michael Jackson 14 年前
父节点
当前提交
b8a14eafe9
共有 4 个文件被更改,包括 5 次插入5 次删除
  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 查看文件

@@ -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 查看文件

@@ -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 查看文件

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

+ 1
- 1
test/_files/escaped.txt 查看文件

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

正在加载...
取消
保存