Permalink
Browse files

Fixed handling of numeric 0 in escapeHTML.

  • Loading branch information...
1 parent cb365fb commit 5388bf2ec8355477a91839dbc36c31509f0e00c1 @cskr committed Dec 7, 2010
Showing with 3 additions and 1 deletion.
  1. +1 −1 grasshopper/lib/helpers.js
  2. +2 −0 test/simple/helpers-test.js
@@ -149,7 +149,7 @@ exports.collectionSelect = function(attribs) {
};
exports.escapeHTML = function(html) {
- if(html) {
+ if(html !== undefined && html !== null) {
return String(html).
replace(/&/gmi, '&').
replace(/"/gmi, '"').
@@ -54,6 +54,8 @@ suite.tests = {
assert.equal(result, 'Hello, <i>Chandru</i>!');
result = helpers.escapeHTML(10);
assert.equal(result, '10');
+ result = helpers.escapeHTML(0);
+ assert.equal(result, '0');
result = helpers.escapeHTML({toString: function() { return 'Hi'; }});
assert.equal(result, 'Hi');
next();

0 comments on commit 5388bf2

Please sign in to comment.