Skip to content

Commit

Permalink
keep htmlEncode and htmlDecode from converting blank strings into emp…
Browse files Browse the repository at this point in the history
…ty strings (e.g., ' ' to '')
  • Loading branch information
Rod Waldhoff committed Feb 8, 2013
1 parent 443006d commit 67bd75b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/encoder.js
Expand Up @@ -34,7 +34,7 @@ exports.Encoder = function(type) {
// Numerically encodes all unicode characters
numEncode : function(s) {

if (this.isEmpty(s)) return "";
if (this.isEmpty(s)) return s;

var e = "";
for (var i = 0; i < s.length; i++) {
Expand All @@ -52,7 +52,7 @@ exports.Encoder = function(type) {

var arr,c,m,d = s;

if (this.isEmpty(d)) return "";
if (this.isEmpty(d)) return d;

// convert HTML entites back to numerical entites first
d = this.HTML2Numerical(d);
Expand Down Expand Up @@ -81,7 +81,7 @@ exports.Encoder = function(type) {
// encode an input string into either numerical or HTML entities
htmlEncode : function(s, dbl) {

if (this.isEmpty(s)) return "";
if (this.isEmpty(s)) return s;

// do we allow double encoding? E.g will &amp; be turned into &amp;amp;
dbl = dbl || false; //default to prevent double encoding
Expand Down Expand Up @@ -158,7 +158,7 @@ exports.Encoder = function(type) {
}
return s;
} else {
return "";
return s;
}
},

Expand Down Expand Up @@ -187,7 +187,7 @@ exports.Encoder = function(type) {

// Function to loop through an array swaping each item with the value from another array e.g swap HTML entities with Numericals
swapArrayVals : function(s, arr1, arr2) {
if (this.isEmpty(s)) return "";
if (this.isEmpty(s)) return s;
var re;
if (arr1 && arr2) {
//ShowDebug("in swapArrayVals arr1.length = " + arr1.length + " arr2.length = " + arr2.length)
Expand All @@ -212,4 +212,3 @@ exports.Encoder = function(type) {
}
}
}

0 comments on commit 67bd75b

Please sign in to comment.