@@ -30740,14 +30740,15 @@ exports.isPlainObject = isPlainObject;
3074030740 var undefined;
3074130741
3074230742 /** Used as the semantic version number. */
30743- var VERSION = '4.17.20 ';
30743+ var VERSION = '4.17.21 ';
3074430744
3074530745 /** Used as the size to enable large array optimizations. */
3074630746 var LARGE_ARRAY_SIZE = 200;
3074730747
3074830748 /** Error message constants. */
3074930749 var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
30750- FUNC_ERROR_TEXT = 'Expected a function';
30750+ FUNC_ERROR_TEXT = 'Expected a function',
30751+ INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';
3075130752
3075230753 /** Used to stand-in for `undefined` hash values. */
3075330754 var HASH_UNDEFINED = '__lodash_hash_undefined__';
@@ -30880,10 +30881,11 @@ exports.isPlainObject = isPlainObject;
3088030881 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
3088130882 reHasRegExpChar = RegExp(reRegExpChar.source);
3088230883
30883- /** Used to match leading and trailing whitespace. */
30884- var reTrim = /^\s+|\s+$/g,
30885- reTrimStart = /^\s+/,
30886- reTrimEnd = /\s+$/;
30884+ /** Used to match leading whitespace. */
30885+ var reTrimStart = /^\s+/;
30886+
30887+ /** Used to match a single whitespace character. */
30888+ var reWhitespace = /\s/;
3088730889
3088830890 /** Used to match wrap detail comments. */
3088930891 var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
@@ -30893,6 +30895,18 @@ exports.isPlainObject = isPlainObject;
3089330895 /** Used to match words composed of alphanumeric characters. */
3089430896 var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
3089530897
30898+ /**
30899+ * Used to validate the `validate` option in `_.template` variable.
30900+ *
30901+ * Forbids characters which could potentially change the meaning of the function argument definition:
30902+ * - "()," (modification of function parameters)
30903+ * - "=" (default value)
30904+ * - "[]{}" (destructuring of function parameters)
30905+ * - "/" (beginning of a comment)
30906+ * - whitespace
30907+ */
30908+ var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
30909+
3089630910 /** Used to match backslashes in property paths. */
3089730911 var reEscapeChar = /\\(\\)?/g;
3089830912
@@ -31721,6 +31735,19 @@ exports.isPlainObject = isPlainObject;
3172131735 });
3172231736 }
3172331737
31738+ /**
31739+ * The base implementation of `_.trim`.
31740+ *
31741+ * @private
31742+ * @param {string} string The string to trim.
31743+ * @returns {string} Returns the trimmed string.
31744+ */
31745+ function baseTrim(string) {
31746+ return string
31747+ ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
31748+ : string;
31749+ }
31750+
3172431751 /**
3172531752 * The base implementation of `_.unary` without support for storing metadata.
3172631753 *
@@ -32054,6 +32081,21 @@ exports.isPlainObject = isPlainObject;
3205432081 : asciiToArray(string);
3205532082 }
3205632083
32084+ /**
32085+ * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
32086+ * character of `string`.
32087+ *
32088+ * @private
32089+ * @param {string} string The string to inspect.
32090+ * @returns {number} Returns the index of the last non-whitespace character.
32091+ */
32092+ function trimmedEndIndex(string) {
32093+ var index = string.length;
32094+
32095+ while (index-- && reWhitespace.test(string.charAt(index))) {}
32096+ return index;
32097+ }
32098+
3205732099 /**
3205832100 * Used by `_.unescape` to convert HTML entities to characters.
3205932101 *
@@ -43222,7 +43264,7 @@ exports.isPlainObject = isPlainObject;
4322243264 if (typeof value != 'string') {
4322343265 return value === 0 ? value : +value;
4322443266 }
43225- value = value.replace(reTrim, '' );
43267+ value = baseTrim(value );
4322643268 var isBinary = reIsBinary.test(value);
4322743269 return (isBinary || reIsOctal.test(value))
4322843270 ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
@@ -45594,6 +45636,12 @@ exports.isPlainObject = isPlainObject;
4559445636 if (!variable) {
4559545637 source = 'with (obj) {\n' + source + '\n}\n';
4559645638 }
45639+ // Throw an error if a forbidden character was found in `variable`, to prevent
45640+ // potential command injection attacks.
45641+ else if (reForbiddenIdentifierChars.test(variable)) {
45642+ throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);
45643+ }
45644+
4559745645 // Cleanup code by stripping empty strings.
4559845646 source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
4559945647 .replace(reEmptyStringMiddle, '$1')
@@ -45707,7 +45755,7 @@ exports.isPlainObject = isPlainObject;
4570745755 function trim(string, chars, guard) {
4570845756 string = toString(string);
4570945757 if (string && (guard || chars === undefined)) {
45710- return string.replace(reTrim, '' );
45758+ return baseTrim(string );
4571145759 }
4571245760 if (!string || !(chars = baseToString(chars))) {
4571345761 return string;
@@ -45742,7 +45790,7 @@ exports.isPlainObject = isPlainObject;
4574245790 function trimEnd(string, chars, guard) {
4574345791 string = toString(string);
4574445792 if (string && (guard || chars === undefined)) {
45745- return string.replace(reTrimEnd, '' );
45793+ return string.slice(0, trimmedEndIndex(string) + 1 );
4574645794 }
4574745795 if (!string || !(chars = baseToString(chars))) {
4574845796 return string;
0 commit comments