Sfoglia il codice sorgente

Escape single quotes to be HTML5 compliant.

HTML tag attributes in HTML5 can use single quotes (') as delimiters.

Patch by Tom Lynn.
tags/0.5.0-vsc
Jan Lehnardt 15 anni fa
parent
commit
60caed99f8
4 ha cambiato i file con 5 aggiunte e 1 eliminazioni
  1. +1
    -0
      examples/apostrophe.html
  2. +1
    -0
      examples/apostrophe.js
  3. +1
    -0
      examples/apostrophe.txt
  4. +2
    -1
      mustache.js

+ 1
- 0
examples/apostrophe.html Vedi File

@@ -0,0 +1 @@
{{apos}}{{control}}

+ 1
- 0
examples/apostrophe.js Vedi File

@@ -0,0 +1 @@
var apostrophe = {'apos': "'", 'control':'X'};

+ 1
- 0
examples/apostrophe.txt Vedi File

@@ -0,0 +1 @@
'X

+ 2
- 1
mustache.js Vedi File

@@ -244,11 +244,12 @@ var Mustache = function() {
*/
escape: function(s) {
s = String(s === null ? "" : s);
return s.replace(/&(?!\w+;)|["<>\\]/g, function(s) {
return s.replace(/&(?!\w+;)|["''<>\\]/g, function(s) {
switch(s) {
case "&": return "&amp;";
case "\\": return "\\\\";
case '"': return '&quot;';
case "'": return '&#39;';
case "<": return "&lt;";
case ">": return "&gt;";
default: return s;


Loading…
Annulla
Salva