Permalink
Browse files

Fixed cross issue from Geddy geddy/geddy#181 where EJS was calling st…

…ring.escapeXML which incorrectly replaced falsey values including 0(Number) with an empty string.

utils.escapeXML now only provides an empty string if the input is NaN, null or undefined.
  • Loading branch information...
1 parent 0ec4381 commit 048203a2002dc17eb7f80afb78b3695ef4bc8358 @larzconwell larzconwell committed Aug 31, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/string.js
View
9 lib/string.js
@@ -46,8 +46,13 @@ string = new (function () {
// Builds the escape/unescape methods using a
// map of characters
_buildEscape = function(direction) {
- return function(string) {
- string = string || '';
+ return function(str) {
+ var string = str;
+
+ // If string is NaN, null or undefined then provide an empty default
+ if(string == null || isNaN(string)) {
+ string = '';
+ }
string = string.toString();
var from, to, p;

1 comment on commit 048203a

@larzconwell
Collaborator

This is actually broke, isNaN was a bad idea to use here. Should we take out the NaN check and just use null/undefined?

Also I need to include some tests for the escaping functions.

Please sign in to comment.