From f49a10ea75d8c238e44b95b9a09fd219acc60960 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 28 Oct 2015 22:29:02 +0500 Subject: [PATCH] lodash: signatures of the method _.escape changed --- lodash/lodash-tests.ts | 16 ++++++++++++++-- lodash/lodash.d.ts | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 3afc49041..0c0516d6a 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -3800,8 +3800,20 @@ module TestEndsWith { } // _.escape -result = _.escape('fred, barney, & pebbles'); -result = _('fred, barney, & pebbles').escape(); +module TestEscape { + { + let result: string; + + result = _.escape('fred, barney, & pebbles'); + result = _('fred, barney, & pebbles').escape(); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _('fred, barney, & pebbles').chain().escape(); + } +} // _.escapeRegExp module TestEscapeRegExp { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index d143f4e65..2bbb24440 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -9234,6 +9234,18 @@ declare module _ { interface LoDashStatic { /** * Converts the characters "&", "<", ">", '"', "'", and "`", in string to their corresponding HTML entities. + * + * Note: No other characters are escaped. To escape additional characters use a third-party library like he. + * + * Though the ">" character is escaped for symmetry, characters like ">" and "/" don’t need escaping in HTML + * and have no special meaning unless they're part of a tag or unquoted attribute value. See Mathias Bynens’s + * article (under "semi-related fun fact") for more details. + * + * Backticks are escaped because in Internet Explorer < 9, they can break out of attribute values or HTML + * comments. See #59, #102, #108, and #133 of the HTML5 Security Cheatsheet for more details. + * + * When working with HTML you should always quote attribute values to reduce XSS vectors. + * * @param string The string to escape. * @return Returns the escaped string. */ @@ -9247,6 +9259,13 @@ declare module _ { escape(): string; } + interface LoDashExplicitWrapper { + /** + * @see _.escape + */ + escape(): LoDashExplicitWrapper; + } + // _.escapeRegExp interface LoDashStatic { /**