mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 17:47:49 +00:00
Fixes Issue #350 -- Making _.escape dumber to allow double-escaping of HTML entities.
This commit is contained in:
@@ -41,6 +41,11 @@ $(document).ready(function() {
|
|||||||
equals(_('champ').myReverse(), 'pmahc', 'mixed in a function to the OOP wrapper');
|
equals(_('champ').myReverse(), 'pmahc', 'mixed in a function to the OOP wrapper');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("utility: _.escape", function() {
|
||||||
|
equals(_.escape("Curly & Moe"), "Curly & Moe");
|
||||||
|
equals(_.escape("Curly & Moe"), "Curly & Moe");
|
||||||
|
});
|
||||||
|
|
||||||
test("utility: template", function() {
|
test("utility: template", function() {
|
||||||
var basicTemplate = _.template("<%= thing %> is gettin' on my noives!");
|
var basicTemplate = _.template("<%= thing %> is gettin' on my noives!");
|
||||||
var result = basicTemplate({thing : 'This'});
|
var result = basicTemplate({thing : 'This'});
|
||||||
|
|||||||
@@ -849,7 +849,7 @@
|
|||||||
|
|
||||||
// Escape a string for HTML interpolation.
|
// Escape a string for HTML interpolation.
|
||||||
_.escape = function(string) {
|
_.escape = function(string) {
|
||||||
return (''+string).replace(/&(?!\w+;|#\d+;|#x[\da-f]+;)/gi, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/');
|
return (''+string).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add your own custom functions to the Underscore object, ensuring that
|
// Add your own custom functions to the Underscore object, ensuring that
|
||||||
|
|||||||
Reference in New Issue
Block a user