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 ede69d2

Browse filesBrowse files
nodejs-github-bottargos
authored andcommitted
deps: update undici to 5.21.2
PR-URL: #47508 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Matthew Aitken <maitken033380023@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
1 parent 64b5a5f commit ede69d2
Copy full SHA for ede69d2

File tree

Expand file treeCollapse file tree

5 files changed

+48
-20
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+48
-20
lines changed
Open diff view settings
Collapse file

‎deps/undici/src/lib/core/util.js‎

Copy file name to clipboardExpand all lines: deps/undici/src/lib/core/util.js
+25-12Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -222,40 +222,53 @@ function parseHeaders (headers, obj = {}) {
222222
const key = headers[i].toString().toLowerCase()
223223
let val = obj[key]
224224

225-
const encoding = key.length === 19 && key === 'content-disposition'
226-
? 'latin1'
227-
: 'utf8'
228-
229225
if (!val) {
230226
if (Array.isArray(headers[i + 1])) {
231227
obj[key] = headers[i + 1]
232228
} else {
233-
obj[key] = headers[i + 1].toString(encoding)
229+
obj[key] = headers[i + 1].toString('utf8')
234230
}
235231
} else {
236232
if (!Array.isArray(val)) {
237233
val = [val]
238234
obj[key] = val
239235
}
240-
val.push(headers[i + 1].toString(encoding))
236+
val.push(headers[i + 1].toString('utf8'))
241237
}
242238
}
239+
240+
// See https://github.com/nodejs/node/pull/46528
241+
if ('content-length' in obj && 'content-disposition' in obj) {
242+
obj['content-disposition'] = Buffer.from(obj['content-disposition']).toString('latin1')
243+
}
244+
243245
return obj
244246
}
245247

246248
function parseRawHeaders (headers) {
247249
const ret = []
250+
let hasContentLength = false
251+
let contentDispositionIdx = -1
252+
248253
for (let n = 0; n < headers.length; n += 2) {
249254
const key = headers[n + 0].toString()
255+
const val = headers[n + 1].toString('utf8')
250256

251-
const encoding = key.length === 19 && key.toLowerCase() === 'content-disposition'
252-
? 'latin1'
253-
: 'utf8'
254-
255-
const val = headers[n + 1].toString(encoding)
257+
if (key.length === 14 && (key === 'content-length' || key.toLowerCase() === 'content-length')) {
258+
ret.push(key, val)
259+
hasContentLength = true
260+
} else if (key.length === 19 && (key === 'content-disposition' || key.toLowerCase() === 'content-disposition')) {
261+
contentDispositionIdx = ret.push(key, val) - 1
262+
} else {
263+
ret.push(key, val)
264+
}
265+
}
256266

257-
ret.push(key, val)
267+
// See https://github.com/nodejs/node/pull/46528
268+
if (hasContentLength && contentDispositionIdx !== -1) {
269+
ret[contentDispositionIdx] = Buffer.from(ret[contentDispositionIdx]).toString('latin1')
258270
}
271+
259272
return ret
260273
}
261274

Collapse file

‎deps/undici/src/lib/fetch/headers.js‎

Copy file name to clipboardExpand all lines: deps/undici/src/lib/fetch/headers.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class HeadersList {
9595
clear () {
9696
this[kHeadersMap].clear()
9797
this[kHeadersSortedMap] = null
98+
this.cookies = null
9899
}
99100

100101
// https://fetch.spec.whatwg.org/#concept-header-list-append
Collapse file

‎deps/undici/src/package.json‎

Copy file name to clipboardExpand all lines: deps/undici/src/package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "undici",
3-
"version": "5.21.1",
3+
"version": "5.21.2",
44
"description": "An HTTP/1.1 client, written from scratch for Node.js",
55
"homepage": "https://undici.nodejs.org",
66
"bugs": {
Collapse file

‎deps/undici/undici.js‎

Copy file name to clipboardExpand all lines: deps/undici/undici.js
+20-6Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -443,30 +443,43 @@ var require_util = __commonJS({
443443
for (let i = 0; i < headers.length; i += 2) {
444444
const key = headers[i].toString().toLowerCase();
445445
let val = obj[key];
446-
const encoding = key.length === 19 && key === "content-disposition" ? "latin1" : "utf8";
447446
if (!val) {
448447
if (Array.isArray(headers[i + 1])) {
449448
obj[key] = headers[i + 1];
450449
} else {
451-
obj[key] = headers[i + 1].toString(encoding);
450+
obj[key] = headers[i + 1].toString("utf8");
452451
}
453452
} else {
454453
if (!Array.isArray(val)) {
455454
val = [val];
456455
obj[key] = val;
457456
}
458-
val.push(headers[i + 1].toString(encoding));
457+
val.push(headers[i + 1].toString("utf8"));
459458
}
460459
}
460+
if ("content-length" in obj && "content-disposition" in obj) {
461+
obj["content-disposition"] = Buffer.from(obj["content-disposition"]).toString("latin1");
462+
}
461463
return obj;
462464
}
463465
function parseRawHeaders(headers) {
464466
const ret = [];
467+
let hasContentLength = false;
468+
let contentDispositionIdx = -1;
465469
for (let n = 0; n < headers.length; n += 2) {
466470
const key = headers[n + 0].toString();
467-
const encoding = key.length === 19 && key.toLowerCase() === "content-disposition" ? "latin1" : "utf8";
468-
const val = headers[n + 1].toString(encoding);
469-
ret.push(key, val);
471+
const val = headers[n + 1].toString("utf8");
472+
if (key.length === 14 && (key === "content-length" || key.toLowerCase() === "content-length")) {
473+
ret.push(key, val);
474+
hasContentLength = true;
475+
} else if (key.length === 19 && (key === "content-disposition" || key.toLowerCase() === "content-disposition")) {
476+
contentDispositionIdx = ret.push(key, val) - 1;
477+
} else {
478+
ret.push(key, val);
479+
}
480+
}
481+
if (hasContentLength && contentDispositionIdx !== -1) {
482+
ret[contentDispositionIdx] = Buffer.from(ret[contentDispositionIdx]).toString("latin1");
470483
}
471484
return ret;
472485
}
@@ -1765,6 +1778,7 @@ var require_headers = __commonJS({
17651778
clear() {
17661779
this[kHeadersMap].clear();
17671780
this[kHeadersSortedMap] = null;
1781+
this.cookies = null;
17681782
}
17691783
append(name, value) {
17701784
this[kHeadersSortedMap] = null;
Collapse file

‎src/undici_version.h‎

Copy file name to clipboardExpand all lines: src/undici_version.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
// Refer to tools/update-undici.sh
33
#ifndef SRC_UNDICI_VERSION_H_
44
#define SRC_UNDICI_VERSION_H_
5-
#define UNDICI_VERSION "5.21.1"
5+
#define UNDICI_VERSION "5.21.2"
66
#endif // SRC_UNDICI_VERSION_H_

0 commit comments

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