Skip to content

Commit b1ebb0d

Browse 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

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/internal/blob.js

Lines 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 {

test/parallel/test-blob.js

Lines 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy