Comparing version 5.21.1 to 5.21.2
@@ -225,6 +225,2 @@ 'use strict' | ||
const encoding = key.length === 19 && key === 'content-disposition' | ||
? 'latin1' | ||
: 'utf8' | ||
if (!val) { | ||
@@ -234,3 +230,3 @@ if (Array.isArray(headers[i + 1])) { | ||
} else { | ||
obj[key] = headers[i + 1].toString(encoding) | ||
obj[key] = headers[i + 1].toString('utf8') | ||
} | ||
@@ -242,5 +238,11 @@ } else { | ||
} | ||
val.push(headers[i + 1].toString(encoding)) | ||
val.push(headers[i + 1].toString('utf8')) | ||
} | ||
} | ||
// See https://github.com/nodejs/node/pull/46528 | ||
if ('content-length' in obj && 'content-disposition' in obj) { | ||
obj['content-disposition'] = Buffer.from(obj['content-disposition']).toString('latin1') | ||
} | ||
return obj | ||
@@ -251,13 +253,24 @@ } | ||
const ret = [] | ||
let hasContentLength = false | ||
let contentDispositionIdx = -1 | ||
for (let n = 0; n < headers.length; n += 2) { | ||
const key = headers[n + 0].toString() | ||
const val = headers[n + 1].toString('utf8') | ||
const encoding = key.length === 19 && key.toLowerCase() === 'content-disposition' | ||
? 'latin1' | ||
: 'utf8' | ||
if (key.length === 14 && (key === 'content-length' || key.toLowerCase() === 'content-length')) { | ||
ret.push(key, val) | ||
hasContentLength = true | ||
} else if (key.length === 19 && (key === 'content-disposition' || key.toLowerCase() === 'content-disposition')) { | ||
contentDispositionIdx = ret.push(key, val) - 1 | ||
} else { | ||
ret.push(key, val) | ||
} | ||
} | ||
const val = headers[n + 1].toString(encoding) | ||
// See https://github.com/nodejs/node/pull/46528 | ||
if (hasContentLength && contentDispositionIdx !== -1) { | ||
ret[contentDispositionIdx] = Buffer.from(ret[contentDispositionIdx]).toString('latin1') | ||
} | ||
ret.push(key, val) | ||
} | ||
return ret | ||
@@ -264,0 +277,0 @@ } |
@@ -98,2 +98,3 @@ // https://github.com/Ethan-Arrowood/undici-fetch | ||
this[kHeadersSortedMap] = null | ||
this.cookies = null | ||
} | ||
@@ -100,0 +101,0 @@ |
{ | ||
"name": "undici", | ||
"version": "5.21.1", | ||
"version": "5.21.2", | ||
"description": "An HTTP/1.1 client, written from scratch for Node.js", | ||
@@ -5,0 +5,0 @@ "homepage": "https://undici.nodejs.org", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1087787
18335