diff --git a/examples/apostrophe.html b/examples/apostrophe.html new file mode 100644 index 0000000..e8687aa --- /dev/null +++ b/examples/apostrophe.html @@ -0,0 +1 @@ +{{apos}}{{control}} diff --git a/examples/apostrophe.js b/examples/apostrophe.js new file mode 100644 index 0000000..df69cd2 --- /dev/null +++ b/examples/apostrophe.js @@ -0,0 +1 @@ +var apostrophe = {'apos': "'", 'control':'X'}; diff --git a/examples/apostrophe.txt b/examples/apostrophe.txt new file mode 100644 index 0000000..4427c30 --- /dev/null +++ b/examples/apostrophe.txt @@ -0,0 +1 @@ +'X diff --git a/mustache.js b/mustache.js index f7b2146..e19109f 100644 --- a/mustache.js +++ b/mustache.js @@ -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 "&"; case "\\": return "\\\\"; case '"': return '"'; + case "'": return '''; case "<": return "<"; case ">": return ">"; default: return s;