summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/utils.js
diff options
context:
space:
mode:
authorBrian Palmer <brianp@instructure.com>2012-02-29 11:25:51 -0700
committerBrian Palmer <brianp@instructure.com>2012-02-29 11:25:51 -0700
commitbd9a84a0b74958ac9ca3fab45c125a6211c378fa (patch)
treeeb6f4595d2431906e24ea930e75a6b847265304e /lib/handlebars/utils.js
parent24e04bad949405dae145d40fbea6a97bafb1c78d (diff)
downloadhandlebars.js-bd9a84a0b74958ac9ca3fab45c125a6211c378fa.zip
handlebars.js-bd9a84a0b74958ac9ca3fab45c125a6211c378fa.tar.gz
handlebars.js-bd9a84a0b74958ac9ca3fab45c125a6211c378fa.tar.bz2
properly handle amperstands when HTML escaping
escapeExpression, when given a string like "&gt;", was simply returning "&gt;", not escaping the amperstand. This is incorrect, and makes it impossible to have Handlebars properly escape a string like "Escaped, <b> looks like: &lt;b&gt;" If the intention of the user is to not escape these characters, then {{{}}} or {{&}} should be used
Diffstat (limited to 'lib/handlebars/utils.js')
-rw-r--r--lib/handlebars/utils.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/handlebars/utils.js b/lib/handlebars/utils.js
index bd5d0eb..b53c9ef 100644
--- a/lib/handlebars/utils.js
+++ b/lib/handlebars/utils.js
@@ -22,6 +22,7 @@ Handlebars.SafeString.prototype.toString = function() {
(function() {
var escape = {
+ "&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': "&quot;",
@@ -29,7 +30,7 @@ Handlebars.SafeString.prototype.toString = function() {
"`": "&#x60;"
};
- var badChars = /&(?!\w+;)|[<>"'`]/g;
+ var badChars = /[&<>"'`]/g;
var possible = /[&<>"'`]/;
var escapeChar = function(chr) {