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 c3acc60

Browse filesBrowse files
committed
Merge commit from fork
* Use crypto.randomInt() Signed-off-by: Matteo Collina <hello@matteocollina.com> * fixup Signed-off-by: Matteo Collina <hello@matteocollina.com> --------- Signed-off-by: Matteo Collina <hello@matteocollina.com>
1 parent 2414bc9 commit c3acc60
Copy full SHA for c3acc60

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/web/fetch/body.js

Copy file name to clipboardExpand all lines: lib/web/fetch/body.js
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ const { isErrored, isDisturbed } = require('node:stream')
2020
const { isArrayBuffer } = require('node:util/types')
2121
const { serializeAMimeType } = require('./data-url')
2222
const { multipartFormDataParser } = require('./formdata-parser')
23+
let random
24+
25+
try {
26+
const crypto = require('node:crypto')
27+
random = (max) => crypto.randomInt(0, max)
28+
} catch {
29+
random = (max) => Math.floor(Math.random(max))
30+
}
2331

2432
const textEncoder = new TextEncoder()
2533
function noop () {}
@@ -113,7 +121,7 @@ function extractBody (object, keepalive = false) {
113121
// Set source to a copy of the bytes held by object.
114122
source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength))
115123
} else if (util.isFormDataLike(object)) {
116-
const boundary = `----formdata-undici-0${`${Math.floor(Math.random() * 1e11)}`.padStart(11, '0')}`
124+
const boundary = `----formdata-undici-0${`${random(1e11)}`.padStart(11, '0')}`
117125
const prefix = `--${boundary}\r\nContent-Disposition: form-data`
118126

119127
/*! 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.