Browse files

escape html only on strings

  • Loading branch information...
1 parent 10fb398 commit fd1a127542fcc3fa2ddc6f7f2e02a96f245ea1f0 @mgutz committed Oct 14, 2012
Showing with 2 additions and 2 deletions.
  1. +1 −1 lib/funcd.js
  2. +1 −1 src/lib/funcd.coffee
View
2 lib/funcd.js
@@ -89,7 +89,7 @@
};
escapeHtml = function(txt) {
- if (txt != null) {
+ if (typeof txt === 'string') {
return txt.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
} else {
return txt;
View
2 src/lib/funcd.coffee
@@ -96,7 +96,7 @@ mergeElements = (args...) ->
# htmlChars = /[&<>"']/g
escapeHtml = (txt) ->
- if txt?
+ if typeof txt == 'string'
txt.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;')
else
txt

0 comments on commit fd1a127

Please sign in to comment.