Skip to content

Commit 3bfbf97

Browse files
enforce latin-1 encoding in source
1 parent b04d65c commit 3bfbf97

16 files changed

+562
-562
lines changed

lib/fetch/body.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function extractBody (object, keepalive = false) {
3636
stream = object
3737
} else if (isBlobLike(object)) {
3838
// 3. Otherwise, if object is a Blob object, set stream to the
39-
// result of running objects get stream.
39+
// result of running object's get stream.
4040
stream = object.stream()
4141
} else {
4242
// 4. Otherwise, set stream to a new ReadableStream object, and set
@@ -87,7 +87,7 @@ function extractBody (object, keepalive = false) {
8787
// See: https://github.com/nodejs/node/blob/e46c680bf2b211bbd52cf959ca17ee98c7f657f5/lib/internal/url.js#L490
8888
// and https://github.com/nodejs/node/blob/e46c680bf2b211bbd52cf959ca17ee98c7f657f5/lib/internal/url.js#L1100
8989

90-
// Set source to the result of running the application/x-www-form-urlencoded serializer with objects list.
90+
// Set source to the result of running the application/x-www-form-urlencoded serializer with object's list.
9191
source = object.toString()
9292

9393
// Set type to `application/x-www-form-urlencoded;charset=UTF-8`.
@@ -106,13 +106,13 @@ function extractBody (object, keepalive = false) {
106106
const boundary = `----formdata-undici-0${`${Math.floor(Math.random() * 1e11)}`.padStart(11, '0')}`
107107
const prefix = `--${boundary}\r\nContent-Disposition: form-data`
108108

109-
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
109+
/*! formdata-polyfill. MIT License. Jimmy Warting <https://jimmy.warting.se/opensource> */
110110
const escape = (str) =>
111111
str.replace(/\n/g, '%0A').replace(/\r/g, '%0D').replace(/"/g, '%22')
112112
const normalizeLinefeeds = (value) => value.replace(/\r?\n|\r/g, '\r\n')
113113

114114
// Set action to this step: run the multipart/form-data
115-
// encoding algorithm, with objects entry list and UTF-8.
115+
// encoding algorithm, with object's entry list and UTF-8.
116116
// - This ensures that the body is immutable and can't be changed afterwords
117117
// - That the content-length is calculated in advance.
118118
// - And that all parts are pre-encoded and ready to be sent.
@@ -174,10 +174,10 @@ function extractBody (object, keepalive = false) {
174174
// Set source to object.
175175
source = object
176176

177-
// Set length to objects size.
177+
// Set length to object's size.
178178
length = object.size
179179

180-
// If objects type attribute is not the empty byte sequence, set
180+
// If object's type attribute is not the empty byte sequence, set
181181
// type to its value.
182182
if (object.type) {
183183
type = object.type
@@ -200,7 +200,7 @@ function extractBody (object, keepalive = false) {
200200
}
201201

202202
// 11. If source is a byte sequence, then set action to a
203-
// step that returns source and length to sources length.
203+
// step that returns source and length to source's length.
204204
if (typeof source === 'string' || util.isBuffer(source)) {
205205
length = Buffer.byteLength(source)
206206
}
@@ -272,14 +272,14 @@ function cloneBody (body) {
272272

273273
// https://fetch.spec.whatwg.org/#concept-body-clone
274274

275-
// 1. Let « out1, out2 » be the result of teeing bodys stream.
275+
// 1. Let « out1, out2 » be the result of teeing body's stream.
276276
const [out1, out2] = body.stream.tee()
277277
const out2Clone = structuredClone(out2, { transfer: [out2] })
278278
// This, for whatever reasons, unrefs out2Clone which allows
279279
// the process to exit by itself.
280280
const [, finalClone] = out2Clone.tee()
281281

282-
// 2. Set bodys stream to out1.
282+
// 2. Set body's stream to out1.
283283
body.stream = out1
284284

285285
// 3. Return a body whose stream is out2 and other members are copied from body.
@@ -325,7 +325,7 @@ function bodyMixinMethods (instance) {
325325
// The blob() method steps are to return the result of
326326
// running consume body with this and the following step
327327
// given a byte sequence bytes: return a Blob whose
328-
// contents are bytes and whose type attribute is thiss
328+
// contents are bytes and whose type attribute is this's
329329
// MIME type.
330330
return specConsumeBody(this, (bytes) => {
331331
let mimeType = bodyMimeType(this)
@@ -373,7 +373,7 @@ function bodyMixinMethods (instance) {
373373

374374
const mimeType = contentType !== null ? parseMIMEType(contentType) : 'failure'
375375

376-
// If mimeTypes essence is "multipart/form-data", then:
376+
// If mimeType's essence is "multipart/form-data", then:
377377
if (mimeType !== 'failure' && mimeType.essence === 'multipart/form-data') {
378378
const headers = {}
379379
for (const [key, value] of this.headers) headers[key] = value
@@ -433,7 +433,7 @@ function bodyMixinMethods (instance) {
433433

434434
return responseFormData
435435
} else if (mimeType !== 'failure' && mimeType.essence === 'application/x-www-form-urlencoded') {
436-
// Otherwise, if mimeTypes essence is "application/x-www-form-urlencoded", then:
436+
// Otherwise, if mimeType's essence is "application/x-www-form-urlencoded", then:
437437

438438
// 1. Let entries be the result of parsing bytes.
439439
let entries
@@ -522,15 +522,15 @@ async function specConsumeBody (object, convertBytesToJSValue, instance) {
522522
}
523523
}
524524

525-
// 5. If objects body is null, then run successSteps with an
525+
// 5. If object's body is null, then run successSteps with an
526526
// empty byte sequence.
527527
if (object[kState].body == null) {
528528
successSteps(new Uint8Array())
529529
return promise.promise
530530
}
531531

532-
// 6. Otherwise, fully read objects body given successSteps,
533-
// errorSteps, and objects relevant global object.
532+
// 6. Otherwise, fully read object's body given successSteps,
533+
// errorSteps, and object's relevant global object.
534534
await fullyReadBody(object[kState].body, successSteps, errorSteps)
535535

536536
// 7. Return promise.
@@ -541,7 +541,7 @@ async function specConsumeBody (object, convertBytesToJSValue, instance) {
541541
function bodyUnusable (body) {
542542
// An object including the Body interface mixin is
543543
// said to be unusable if its body is non-null and
544-
// its bodys stream is disturbed or locked.
544+
// its body's stream is disturbed or locked.
545545
return body != null && (body.stream.locked || util.isDisturbed(body.stream))
546546
}
547547

@@ -563,7 +563,7 @@ function utf8DecodeBytes (buffer) {
563563
buffer = buffer.subarray(3)
564564
}
565565

566-
// 3. Process a queue with an instance of UTF-8s
566+
// 3. Process a queue with an instance of UTF-8's
567567
// decoder, ioQueue, output, and "replacement".
568568
const output = textDecoder.decode(buffer)
569569

lib/fetch/dataURL.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const HTTP_QUOTED_STRING_TOKENS = /[\u0009|\u0020-\u007E|\u0080-\u00FF]/ // esli
1717
// https://fetch.spec.whatwg.org/#data-url-processor
1818
/** @param {URL} dataURL */
1919
function dataURLProcessor (dataURL) {
20-
// 1. Assert: dataURLs scheme is "data".
20+
// 1. Assert: dataURL's scheme is "data".
2121
assert(dataURL.protocol === 'data:')
2222

2323
// 2. Let input be the result of running the URL
@@ -145,7 +145,7 @@ function collectASequenceOfCodePoints (condition, input, position) {
145145
// 1. Let result be the empty string.
146146
let result = ''
147147

148-
// 2. While position doesnt point past the end of input and the
148+
// 2. While position doesn't point past the end of input and the
149149
// code point at position within input meets the condition condition:
150150
while (position.position < input.length && condition(input[position.position])) {
151151
// 1. Append that code point to the end of result.
@@ -410,8 +410,8 @@ function parseMIMEType (input) {
410410
// - parameterName is not the empty string
411411
// - parameterName solely contains HTTP token code points
412412
// - parameterValue solely contains HTTP quoted-string token code points
413-
// - mimeTypes parameters[parameterName] does not exist
414-
// then set mimeTypes parameters[parameterName] to parameterValue.
413+
// - mimeType's parameters[parameterName] does not exist
414+
// then set mimeType's parameters[parameterName] to parameterValue.
415415
if (
416416
parameterName.length !== 0 &&
417417
HTTP_TOKEN_CODEPOINTS.test(parameterName) &&
@@ -433,7 +433,7 @@ function forgivingBase64 (data) {
433433
data = data.replace(ASCII_WHITESPACE_REPLACE_REGEX, '') // eslint-disable-line
434434

435435
let dataLength = data.length
436-
// 2. If datas code point length divides by 4 leaving
436+
// 2. If data's code point length divides by 4 leaving
437437
// no remainder, then:
438438
if (dataLength % 4 === 0) {
439439
// 1. If data ends with one or two U+003D (=) code points,
@@ -446,7 +446,7 @@ function forgivingBase64 (data) {
446446
}
447447
}
448448

449-
// 3. If datas code point length divides by 4 leaving
449+
// 3. If data's code point length divides by 4 leaving
450450
// a remainder of 1, then return failure.
451451
if (dataLength % 4 === 1) {
452452
return 'failure'
@@ -551,11 +551,11 @@ function serializeAMimeType (mimeType) {
551551
assert(mimeType !== 'failure')
552552
const { parameters, essence } = mimeType
553553

554-
// 1. Let serialization be the concatenation of mimeTypes
555-
// type, U+002F (/), and mimeTypes subtype.
554+
// 1. Let serialization be the concatenation of mimeType's
555+
// type, U+002F (/), and mimeType's subtype.
556556
let serialization = essence
557557

558-
// 2. For each name → value of mimeTypes parameters:
558+
// 2. For each name → value of mimeType's parameters:
559559
for (let [name, value] of parameters.entries()) {
560560
// 1. Append U+003B (;) to serialization.
561561
serialization += ';'

lib/fetch/file.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ function convertLineEndingsNative (s) {
309309
// 1. Let native line ending be be the code point U+000A LF.
310310
let nativeLineEnding = '\n'
311311

312-
// 2. If the underlying platforms conventions are to
312+
// 2. If the underlying platform's conventions are to
313313
// represent newlines as a carriage return and line feed
314314
// sequence, set native line ending to the code point
315315
// U+000D CR followed by the code point U+000A LF.

lib/fetch/formdata.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class FormData {
4848
// name, value, and filename if given.
4949
const entry = makeEntry(name, value, filename)
5050

51-
// 3. Append entry to thiss entry list.
51+
// 3. Append entry to this's entry list.
5252
this[kState].push(entry)
5353
}
5454

@@ -60,7 +60,7 @@ class FormData {
6060
name = webidl.converters.USVString(name)
6161

6262
// The delete(name) method steps are to remove all entries whose name
63-
// is name from thiss entry list.
63+
// is name from this's entry list.
6464
this[kState] = this[kState].filter(entry => entry.name !== name)
6565
}
6666

@@ -71,15 +71,15 @@ class FormData {
7171

7272
name = webidl.converters.USVString(name)
7373

74-
// 1. If there is no entry whose name is name in thiss entry list,
74+
// 1. If there is no entry whose name is name in this's entry list,
7575
// then return null.
7676
const idx = this[kState].findIndex((entry) => entry.name === name)
7777
if (idx === -1) {
7878
return null
7979
}
8080

8181
// 2. Return the value of the first entry whose name is name from
82-
// thiss entry list.
82+
// this's entry list.
8383
return this[kState][idx].value
8484
}
8585

@@ -90,10 +90,10 @@ class FormData {
9090

9191
name = webidl.converters.USVString(name)
9292

93-
// 1. If there is no entry whose name is name in thiss entry list,
93+
// 1. If there is no entry whose name is name in this's entry list,
9494
// then return the empty list.
9595
// 2. Return the values of all entries whose name is name, in order,
96-
// from thiss entry list.
96+
// from this's entry list.
9797
return this[kState]
9898
.filter((entry) => entry.name === name)
9999
.map((entry) => entry.value)
@@ -107,7 +107,7 @@ class FormData {
107107
name = webidl.converters.USVString(name)
108108

109109
// The has(name) method steps are to return true if there is an entry
110-
// whose name is name in thiss entry list; otherwise false.
110+
// whose name is name in this's entry list; otherwise false.
111111
return this[kState].findIndex((entry) => entry.name === name) !== -1
112112
}
113113

@@ -139,7 +139,7 @@ class FormData {
139139
// filename if given.
140140
const entry = makeEntry(name, value, filename)
141141

142-
// 3. If there are entries in thiss entry list whose name is name, then
142+
// 3. If there are entries in this's entry list whose name is name, then
143143
// replace the first such entry with entry and remove the others.
144144
const idx = this[kState].findIndex((entry) => entry.name === name)
145145
if (idx !== -1) {
@@ -149,7 +149,7 @@ class FormData {
149149
...this[kState].slice(idx + 1).filter((entry) => entry.name !== name)
150150
]
151151
} else {
152-
// 4. Otherwise, append entry to thiss entry list.
152+
// 4. Otherwise, append entry to this's entry list.
153153
this[kState].push(entry)
154154
}
155155
}

0 commit comments

Comments
 (0)