summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2015-09-01 01:44:35 -0500
committerHannah Wolfe <erisds@gmail.com>2016-02-08 18:56:04 +0000
commit1c863e34abf04ba6a0095078658d334646aca5cc (patch)
tree46ec576e08cdefca628b1858f0ce24a3424075ce
parent891f48b7e9c321dd9cbe7a898533eb6b2434b8a0 (diff)
downloadhandlebars.js-1c863e34abf04ba6a0095078658d334646aca5cc.zip
handlebars.js-1c863e34abf04ba6a0095078658d334646aca5cc.tar.gz
handlebars.js-1c863e34abf04ba6a0095078658d334646aca5cc.tar.bz2
Escape = in HTML content
There was a potential XSS exploit when using unquoted attributes that this should help reduce. Fixes #1083
-rw-r--r--lib/handlebars/utils.js7
-rw-r--r--spec/utils.js1
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/handlebars/utils.js b/lib/handlebars/utils.js
index c522394..fc6dcfb 100644
--- a/lib/handlebars/utils.js
+++ b/lib/handlebars/utils.js
@@ -4,11 +4,12 @@ const escape = {
'>': '&gt;',
'"': '&quot;',
"'": '&#x27;',
- '`': '&#x60;'
+ '`': '&#x60;',
+ '=': '&#x3D;'
};
-const badChars = /[&<>"'`]/g,
- possible = /[&<>"'`]/;
+const badChars = /[&<>"'`=]/g,
+ possible = /[&<>"'`=]/;
function escapeChar(chr) {
return escape[chr];
diff --git a/spec/utils.js b/spec/utils.js
index 81732c5..7248ac4 100644
--- a/spec/utils.js
+++ b/spec/utils.js
@@ -18,6 +18,7 @@ describe('utils', function() {
describe('#escapeExpression', function() {
it('shouhld escape html', function() {
equals(Handlebars.Utils.escapeExpression('foo<&"\'>'), 'foo&lt;&amp;&quot;&#x27;&gt;');
+ equals(Handlebars.Utils.escapeExpression('foo='), 'foo&#x3D;');
});
it('should not escape SafeString', function() {
var string = new Handlebars.SafeString('foo<&"\'>');