Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fda56b9

Browse filesBrowse files
gurgundayaduh95
authored andcommitted
lib: limit split function calls to prevent excessive array length
PR-URL: #57501 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me>
1 parent 4b04c92 commit fda56b9
Copy full SHA for fda56b9

File tree

Expand file treeCollapse file tree

12 files changed

+12
-11
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

12 files changed

+12
-11
lines changed
Open diff view settings
Collapse file

‎lib/internal/blob.js‎

Copy file name to clipboardExpand all lines: lib/internal/blob.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ function resolveObjectURL(url) {
360360
try {
361361
const parsed = new URL(url);
362362

363-
const split = StringPrototypeSplit(parsed.pathname, ':');
363+
const split = StringPrototypeSplit(parsed.pathname, ':', 3);
364364

365365
if (split.length !== 2)
366366
return;
Collapse file

‎lib/internal/debugger/inspect.js‎

Copy file name to clipboardExpand all lines: lib/internal/debugger/inspect.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class NodeInspector {
160160
this[domain] = createAgentProxy(domain, this.client);
161161
});
162162
this.handleDebugEvent = (fullName, params) => {
163-
const { 0: domain, 1: name } = StringPrototypeSplit(fullName, '.');
163+
const { 0: domain, 1: name } = StringPrototypeSplit(fullName, '.', 2);
164164
if (domain in this) {
165165
this[domain].emit(name, params);
166166
}
Collapse file

‎lib/internal/errors.js‎

Copy file name to clipboardExpand all lines: lib/internal/errors.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ const fatalExceptionStackEnhancers = {
907907
// ANSI escape sequences is not reliable.
908908
if (isWindows) {
909909
const info = internalBinding('os').getOSInformation();
910-
const ver = ArrayPrototypeMap(StringPrototypeSplit(info[2], '.'),
910+
const ver = ArrayPrototypeMap(StringPrototypeSplit(info[2], '.', 3),
911911
Number);
912912
if (ver[0] !== 10 || ver[2] < 14393) {
913913
useColors = false;
Collapse file

‎lib/internal/modules/cjs/loader.js‎

Copy file name to clipboardExpand all lines: lib/internal/modules/cjs/loader.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,7 @@ function reconstructErrorStack(err, parentPath, parentSource) {
18331833
const { 1: line, 2: col } =
18341834
RegExpPrototypeExec(/(\d+):(\d+)\)/, errLine) || [];
18351835
if (line && col) {
1836-
const srcLine = StringPrototypeSplit(parentSource, '\n')[line - 1];
1836+
const srcLine = StringPrototypeSplit(parentSource, '\n', line)[line - 1];
18371837
const frame = `${parentPath}:${line}\n${srcLine}\n${StringPrototypeRepeat(' ', col - 1)}^\n`;
18381838
setArrowMessage(err, frame);
18391839
}
Collapse file

‎lib/internal/modules/esm/module_job.js‎

Copy file name to clipboardExpand all lines: lib/internal/modules/esm/module_job.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ class ModuleJob extends ModuleJobBase {
190190
if (!getSourceMapsSupport().enabled &&
191191
StringPrototypeIncludes(e.message,
192192
' does not provide an export named')) {
193-
const splitStack = StringPrototypeSplit(e.stack, '\n');
193+
const splitStack = StringPrototypeSplit(e.stack, '\n', 2);
194194
const parentFileUrl = RegExpPrototypeSymbolReplace(
195195
/:\d+$/,
196196
splitStack[0],
Collapse file

‎lib/internal/repl/await.js‎

Copy file name to clipboardExpand all lines: lib/internal/repl/await.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ function processTopLevelAwait(src) {
178178
return null;
179179
const line = e.loc.line;
180180
const column = line === 1 ? e.loc.column - wrapPrefix.length : e.loc.column;
181-
let message = '\n' + StringPrototypeSplit(src, '\n')[line - 1] + '\n' +
181+
let message = '\n' + StringPrototypeSplit(src, '\n', line)[line - 1] + '\n' +
182182
StringPrototypeRepeat(' ', column) +
183183
'^\n\n' + RegExpPrototypeSymbolReplace(/ \([^)]+\)/, e.message, '');
184184
// V8 unexpected token errors include the token string.
Collapse file

‎lib/internal/source_map/source_map_cache.js‎

Copy file name to clipboardExpand all lines: lib/internal/source_map/source_map_cache.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ function sourceMapFromFile(mapURL) {
292292
// data:[<mediatype>][;base64],<data> see:
293293
// https://tools.ietf.org/html/rfc2397#section-2
294294
function sourceMapFromDataUrl(sourceURL, url) {
295-
const { 0: format, 1: data } = StringPrototypeSplit(url, ',');
295+
const { 0: format, 1: data } = StringPrototypeSplit(url, ',', 2);
296296
const splitFormat = StringPrototypeSplit(format, ';');
297297
const contentType = splitFormat[0];
298298
const base64 = splitFormat[splitFormat.length - 1] === 'base64';
Collapse file

‎lib/internal/test_runner/utils.js‎

Copy file name to clipboardExpand all lines: lib/internal/test_runner/utils.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ function parseCommandLine() {
263263
);
264264
}
265265

266-
const indexAndTotal = StringPrototypeSplit(shardOption, '/');
266+
const indexAndTotal = StringPrototypeSplit(shardOption, '/', 2);
267267
shard = {
268268
__proto__: null,
269269
index: NumberParseInt(indexAndTotal[0], 10),
Collapse file

‎lib/internal/tty.js‎

Copy file name to clipboardExpand all lines: lib/internal/tty.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ function getColorDepth(env = process.env) {
138138
// Lazy load for startup performance.
139139
if (OSRelease === undefined) {
140140
const { release } = require('os');
141-
OSRelease = StringPrototypeSplit(release(), '.');
141+
OSRelease = StringPrototypeSplit(release(), '.', 3);
142142
}
143143
// Windows 10 build 10586 is the first Windows release that supports 256
144144
// colors. Windows 10 build 14931 is the first release that supports
Collapse file

‎lib/internal/util/debuglog.js‎

Copy file name to clipboardExpand all lines: lib/internal/util/debuglog.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ function formatTime(ms) {
160160
({ 0: seconds, 1: ms } = StringPrototypeSplit(
161161
NumberPrototypeToFixed(seconds, 3),
162162
'.',
163+
2,
163164
));
164165
const res = hours !== 0 ? `${hours}:${pad(minutes)}` : minutes;
165166
return `${res}:${pad(seconds)}.${ms} (${hours !== 0 ? 'h:m' : ''}m:ss.mmm)`;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.