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 b1ebb0d

Browse filesBrowse files
aduh95targos
authored andcommitted
buffer: coerce extrema to int in blob.slice
PR-URL: #55141 Fixes: #55139 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 1240197 commit b1ebb0d
Copy full SHA for b1ebb0d

File tree

Expand file treeCollapse file tree

2 files changed

+8
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-0
lines changed
Open diff view settings
Collapse file

‎lib/internal/blob.js‎

Copy file name to clipboardExpand all lines: lib/internal/blob.js
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const {
5454
lazyDOMException,
5555
} = require('internal/util');
5656
const { inspect } = require('internal/util/inspect');
57+
const { convertToInt } = require('internal/webidl');
5758

5859
const {
5960
codes: {
@@ -239,6 +240,12 @@ class Blob {
239240
slice(start = 0, end = this[kLength], contentType = '') {
240241
if (!isBlob(this))
241242
throw new ERR_INVALID_THIS('Blob');
243+
244+
// Coerce values to int
245+
const opts = { __proto__: null, signed: true };
246+
start = convertToInt('start', start, 64, opts);
247+
end = convertToInt('end', end, 64, opts);
248+
242249
if (start < 0) {
243250
start = MathMax(this[kLength] + start, 0);
244251
} else {
Collapse file

‎test/parallel/test-blob.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-blob.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ assert.throws(() => new Blob({}), {
483483

484484
assert.ok(blob.slice(0, 1).constructor === Blob);
485485
assert.ok(blob.slice(0, 1) instanceof Blob);
486+
assert.ok(blob.slice(0, 1.5) instanceof Blob);
486487
}
487488

488489
(async () => {

0 commit comments

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