Fixes Issue #350 -- Making _.escape dumber to allow double-escaping of HTML entities.

This commit is contained in:
Jeremy Ashkenas
2011-10-31 12:31:02 -04:00
parent 64b69c0cfa
commit ba96d168ec
2 changed files with 6 additions and 1 deletions

View File

@@ -849,7 +849,7 @@
// Escape a string for HTML interpolation.
_.escape = function(string) {
return (''+string).replace(/&(?!\w+;|#\d+;|#x[\da-f]+;)/gi, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/\//g,'&#x2F;');
return (''+string).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/\//g,'&#x2F;');
};
// Add your own custom functions to the Underscore object, ensuring that