diff --git a/dist/handlebars.js b/dist/handlebars.js index 5bd69b5c8..7942d5e9a 100644 --- a/dist/handlebars.js +++ b/dist/handlebars.js @@ -825,6 +825,11 @@ Handlebars.Utils = { return ""; } + // Force a string conversion as this will be done by the append regardless and + // the regex test will do this transparently behind the scenes, causing issues if + // an object's to string has escaped characters in it. + string = string.toString(); + if(!possible.test(string)) { return string; } return string.replace(badChars, escapeChar); }, diff --git a/dist/handlebars.runtime.js b/dist/handlebars.runtime.js index 4779ad0a3..1c9b9225a 100644 --- a/dist/handlebars.runtime.js +++ b/dist/handlebars.runtime.js @@ -211,6 +211,11 @@ Handlebars.Utils = { return ""; } + // Force a string conversion as this will be done by the append regardless and + // the regex test will do this transparently behind the scenes, causing issues if + // an object's to string has escaped characters in it. + string = string.toString(); + if(!possible.test(string)) { return string; } return string.replace(badChars, escapeChar); }, diff --git a/lib/handlebars/utils.js b/lib/handlebars/utils.js index 85c1a9408..7d9da1741 100644 --- a/lib/handlebars/utils.js +++ b/lib/handlebars/utils.js @@ -47,6 +47,11 @@ Handlebars.Utils = { return ""; } + // Force a string conversion as this will be done by the append regardless and + // the regex test will do this transparently behind the scenes, causing issues if + // an object's to string has escaped characters in it. + string = string.toString(); + if(!possible.test(string)) { return string; } return string.replace(badChars, escapeChar); },