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 711e207

Browse filesBrowse files
committed
Backport of c2d78cd
Signed-off-by: Matteo Collina <hello@matteocollina.com>
1 parent fb98306 commit 711e207
Copy full SHA for 711e207

File tree

Expand file treeCollapse file tree

1 file changed

+9
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-1
lines changed

‎lib/fetch/body.js

Copy file name to clipboardExpand all lines: lib/fetch/body.js
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ const { isUint8Array, isArrayBuffer } = require('util/types')
2222
const { File: UndiciFile } = require('./file')
2323
const { parseMIMEType, serializeAMimeType } = require('./dataURL')
2424

25+
let random
26+
try {
27+
const crypto = require('node:crypto')
28+
random = (max) => crypto.randomInt(0, max)
29+
} catch {
30+
random = (max) => Math.floor(Math.random(max))
31+
}
32+
2533
let ReadableStream = globalThis.ReadableStream
2634

2735
/** @type {globalThis['File']} */
@@ -107,7 +115,7 @@ function extractBody (object, keepalive = false) {
107115
// Set source to a copy of the bytes held by object.
108116
source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength))
109117
} else if (util.isFormDataLike(object)) {
110-
const boundary = `----formdata-undici-0${`${Math.floor(Math.random() * 1e11)}`.padStart(11, '0')}`
118+
const boundary = `----formdata-undici-0${`${random(1e11)}`.padStart(11, '0')}`
111119
const prefix = `--${boundary}\r\nContent-Disposition: form-data`
112120

113121
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */

0 commit comments

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