8000 Bump to v4.17.21 · lodash/lodash@11eb817 · GitHub
[go: up one dir, main page]

Skip to content

Commit 11eb817

Browse files
committed
Bump to v4.17.21
1 parent 42e2585 commit 11eb817

11 files changed

+71
-18
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# lodash-es v4.17.20
1+
# lodash-es v4.17.21
22

33
The [Lodash](https://lodash.com/) library exported as [ES](http://www.ecma-international.org/ecma-262/6.0/) modules.
44

@@ -7,4 +7,4 @@ Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
77
$ lodash modularize exports=es -o ./
88
```
99

10-
See the [package source](https://github.com/lodash/lodash/tree/4.17.20-es) for more details.
10+
See the [package source](https://github.com/lodash/lodash/tree/4.17.21-es) for more details.

_baseTrim.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import trimmedEndIndex from './_trimmedEndIndex.js';
2+
3+
/** Used to match leading whitespace. */
4+
var reTrimStart = /^\s+/;
5+
6+
/**
7+
* The base implementation of `_.trim`.
8+
*
9+
* @private
10+
* @param {string} string The string to trim.
11+
* @returns {string} Returns the trimmed string.
12+
*/
13+
function baseTrim(string) {
14+
return string
15+
? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
16+
: string;
17+
}
18+
19+
export default baseTrim;

_trimmedEndIndex.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/** Used to match a single whitespace character. */
2+
var reWhitespace = /\s/;
3+
4+
/**
5+
* Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
6+
* character of `string`.
7+
*
8+
* @private
9+
* @param {string} string The string to inspect.
10+
* @returns {number} Returns the index of the last non-whitespace character.
11+
*/
12+
function trimmedEndIndex(string) {
13+
var index = string.length;
14+
15+
while (index-- && reWhitespace.test(string.charAt(index))) {}
16+
return index;
17+
}
18+
19+
export default trimmedEndIndex;

lodash.default.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import toInteger from './toInteger.js';
4545
import lodash from './wrapperLodash.js';
4646

4747
/** Used as the semantic version number. */
48-
var VERSION = '4.17.20';
48+
var VERSION = '4.17.21';
4949

5050
/** Used to compose bitmasks for function metadata. */
5151
var WRAP_BIND_KEY_FLAG = 2;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lodash-es",
3-
"version": "4.17.20",
3+
"version": "4.17.21",
44
"description": "Lodash exported as ES modules.",
55
"keywords": "es6, modules, stdlib, util",
66
"homepage": "https://lodash.com/custom-builds",

parseInt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import root from './_root.js';
22
import toString from './toString.js';
33

4-
/** Used to match leading and trailing whitespace. */
4+
/** Used to match leading whitespace. */
55
var reTrimStart = /^\s+/;
66

77
/* Built-in method references for those with the same name as other `lodash` methods. */

template.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,26 @@ import reInterpolate from './_reInterpolate.js';
1010
import templateSettings from './templateSettings.js';
1111
import toString from './toString.js';
1212

13+
/** Error message constants. */
14+
var INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';
15+
1316
/** Used to match empty string literals in compiled template source. */
1417
var reEmptyStringLeading = /\b__p \+= '';/g,
1518
reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
1619
reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
1720

21+
/**
22+
* Used to validate the `validate` option in `_.template` variable.
23+
*
24+
* Forbids characters which could potentially change the meaning of the function argument definition:
25+
* - "()," (modification of function parameters)
26+
* - "=" (default value)
27+
* - "[]{}" (destructuring of function parameters)
28+
* - "/" (beginning of a comment)
29+
* - whitespace
30+
*/
31+
var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
32+
1833
/**
1934
* Used to match
2035
* [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
@@ -210,6 +225,12 @@ function template(string, options, guard) {
210225
if (!variable) {
211226
source = 'with (obj) {\n' + source + '\n}\n';
212227
}
228+
// Throw an error if a forbidden character was found in `variable`, to prevent
229+
// potential command injection attacks.
230+
else if (reForbiddenIdentifierChars.test(variable)) {
231+
throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);
232+
}
233+
213234
// Cleanup code by stripping empty strings.
214235
source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
215236
.replace(reEmptyStringMiddle, '$1')

toNumber.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1+
import baseTrim from './_baseTrim.js';
12
import isObject from './isObject.js';
23
import isSymbol from './isSymbol.js';
34

45
/** Used as references for various `Number` constants. */
56
var NAN = 0 / 0;
67

7-
/** Used to match leading and trailing whitespace. */
8-
var reTrim = /^\s+|\s+$/g;
9-
108
/** Used to detect bad signed hexadecimal string values. */
119
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
1210

@@ -56,7 +54,7 @@ function toNumber(value) {
5654
if (typeof value != 'string') {
5755
return value === 0 ? value : +value;
5856
}
59-
value = value.replace(reTrim, '');
57+
value = baseTrim(value);
6058
var isBinary = reIsBinary.test(value);
6159
return (isBinary || reIsOctal.test(value))
6260
? freeParseInt(value.slice(2), isBinary ? 2 : 8)

trim.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import baseToString from './_baseToString.js';
2+
import baseTrim from './_baseTrim.js';
23
import castSlice from './_castSlice.js';
34
import charsEndIndex from './_charsEndIndex.js';
45
import charsStartIndex from './_charsStartIndex.js';
56
import stringToArray from './_stringToArray.js';
67
import toString from './toString.js';
78

8-
/** Used to match leading and trailing whitespace. */
9-
var reTrim = /^\s+|\s+$/g;
10-
119
/**
1210
* Removes leading and trailing whitespace or specified characters from `string`.
1311
*
@@ -33,7 +31,7 @@ var reTrim = /^\s+|\s+$/g;
3331
function trim(string, chars, guard) {
3432
string = toString(string);
3533
if (string && (guard || chars === undefined)) {
36-
return string.replace(reTrim, '');
34+
return baseTrim(string);
3735
}
3836
if (!string || !(chars = baseToString(chars))) {
3937
return string;

trimEnd.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 F480 +3,7 @@ import castSlice from './_castSlice.js';
33
import charsEndIndex from './_charsEndIndex.js';
44
import stringToArray from './_stringToArray.js';
55
import toString from './toString.js';
6-
7-
/** Used to match leading and trailing whitespace. */
8-
var reTrimEnd = /\s+$/;
6+
import trimmedEndIndex from './_trimmedEndIndex.js';
97

108
/**
119
* Removes trailing whitespace or specified characters from `string`.
@@ -29,7 +27,7 @@ var reTrimEnd = /\s+$/;
2927
function trimEnd(string, chars, guard) {
3028
string = toString(string);
3129
if (string && (guard || chars === undefined)) {
32-
return string.replace(reTrimEnd, '');
30+
return string.slice(0, trimmedEndIndex(string) + 1);
3331
}
3432
if (!string || !(chars = baseToString(chars))) {
3533
return string;

trimStart.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import charsStartIndex from './_charsStartIndex.js';
44
import stringToArray from './_stringToArray.js';
55
import toString from './toString.js';
66

7-
/** Used to match leading and trailing whitespace. */
7+
/** Used to match leading whitespace. */
88
var reTrimStart = /^\s+/;
99

1010
/**

0 commit comments

Comments
 (0)
0