mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
buffer: coerce extrema to int in blob.slice
PR-URL: https://github.com/nodejs/node/pull/55141 Fixes: https://github.com/nodejs/node/issues/55139 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
e973c3e94b
commit
4062b3fb43
2 changed files with 8 additions and 0 deletions
|
@ -54,6 +54,7 @@ const {
|
|||
lazyDOMException,
|
||||
} = require('internal/util');
|
||||
const { inspect } = require('internal/util/inspect');
|
||||
const { convertToInt } = require('internal/webidl');
|
||||
|
||||
const {
|
||||
codes: {
|
||||
|
@ -239,6 +240,12 @@ class Blob {
|
|||
slice(start = 0, end = this[kLength], contentType = '') {
|
||||
if (!isBlob(this))
|
||||
throw new ERR_INVALID_THIS('Blob');
|
||||
|
||||
// Coerce values to int
|
||||
const opts = { __proto__: null, signed: true };
|
||||
start = convertToInt('start', start, 64, opts);
|
||||
end = convertToInt('end', end, 64, opts);
|
||||
|
||||
if (start < 0) {
|
||||
start = MathMax(this[kLength] + start, 0);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue