diff options
author | Tommy Messbauer <tommy@vast.com> | 2012-11-26 10:26:15 -0600 |
---|---|---|
committer | Tommy Messbauer <tommy@vast.com> | 2012-11-26 10:26:15 -0600 |
commit | db975b42a0ae295b6716700900a4724d97f1d9c6 (patch) | |
tree | 9d33e5c1ab8c279698cb58894711ac6f1282ec67 /lib/handlebars/utils.js | |
parent | 79632184953284603b64a3179d087ebcda9d0ab6 (diff) | |
parent | bd0490145438e8f9df05abd2f4c25687bac81326 (diff) | |
download | handlebars.js-db975b42a0ae295b6716700900a4724d97f1d9c6.zip handlebars.js-db975b42a0ae295b6716700900a4724d97f1d9c6.tar.gz handlebars.js-db975b42a0ae295b6716700900a4724d97f1d9c6.tar.bz2 |
Merged upstream master and ran unit tests
Diffstat (limited to 'lib/handlebars/utils.js')
-rw-r--r-- | lib/handlebars/utils.js | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/handlebars/utils.js b/lib/handlebars/utils.js index d467205..cd02e95 100644 --- a/lib/handlebars/utils.js +++ b/lib/handlebars/utils.js @@ -2,14 +2,15 @@ exports.attach = function(Handlebars) { // BEGIN(BROWSER) +var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack']; + Handlebars.Exception = function(message) { var tmp = Error.prototype.constructor.apply(this, arguments); - for (var p in tmp) { - if (tmp.hasOwnProperty(p)) { this[p] = tmp[p]; } + // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work. + for (var idx = 0; idx < errorProps.length; idx++) { + this[errorProps[idx]] = tmp[errorProps[idx]]; } - - this.message = tmp.message; }; Handlebars.Exception.prototype = new Error(); @@ -23,6 +24,7 @@ Handlebars.SafeString.prototype.toString = function() { (function() { var escape = { + "&": "&", "<": "<", ">": ">", '"': """, @@ -30,7 +32,7 @@ Handlebars.SafeString.prototype.toString = function() { "`": "`" }; - var badChars = /&(?!\w+;)|[<>"'`]/g; + var badChars = /[&<>"'`]/g; var possible = /[&<>"'`]/; var escapeChar = function(chr) { |