Skip to content
Browse files

Add missing escape ' escape

  • Loading branch information...
1 parent 0e968ca commit 06f45faccf89009dfb8656f32373f7f0efa9067c @felixge felixge committed Jul 20, 2011
Showing with 5 additions and 3 deletions.
  1. +3 −2 lib/util.js
  2. +2 −1 test/test.js
View
5 lib/util.js
@@ -2,15 +2,16 @@
var XML_CHARACTER_MAP = {
'&': '&',
'"': '"',
+ "'": ''',
'<': '&lt;',
'>': '&gt;'
};
function xml_safe(string) {
- return string && string.replace ? string.replace(/([&"<>])/g, function(str, item) {
+ return string && string.replace ? string.replace(/([&"<>'])/g, function(str, item) {
return XML_CHARACTER_MAP[item];
})
: string;
}
-module.exports.xml_safe = xml_safe;
+module.exports.xml_safe = xml_safe;
View
3 test/test.js
@@ -13,6 +13,7 @@ module.exports = {
test.equal(XML('test'), 'test');
test.equal(XML('test'), 'test');
test.equal(XML('scotch & whisky'), 'scotch &amp; whisky');
+ test.equal(XML('bob\'s escape character'), 'bob&apos;s escape character');
test.done();
},
@@ -85,4 +86,4 @@ module.exports = {
}, 1);
}
-};
+};

0 comments on commit 06f45fa

Please sign in to comment.
Something went wrong with that request. Please try again.