Skip to content

Commit bcfe21d

Browse files
nodejs-github-botRafaelGSS
authored andcommitted
deps: update undici to 7.29.0
PR-URL: #64713 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
1 parent 05f541b commit bcfe21d

16 files changed

Lines changed: 1199 additions & 435 deletions

File tree

‎deps/undici/src/lib/cache/memory-cache-store.js‎

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -218,17 +218,62 @@ class MemoryCacheStore extends EventEmitter {
218218
}
219219

220220
functionfindEntry(key,entries,now){
221-
returnentries.find((entry)=>(
222-
entry.deleteAt>now&&
223-
entry.method===key.method&&
224-
(entry.vary==null||Object.keys(entry.vary).every(headerName=>{
225-
if(entry.vary[headerName]===null){
226-
returnkey.headers[headerName]===undefined
221+
for(leti=0;i<entries.length;i++){
222+
constentry=entries[i]
223+
if(
224+
entry.deleteAt>now&&
225+
entry.method===key.method&&
226+
varyMatches(key,entry)
227+
){
228+
returnentry
229+
}
230+
}
231+
}
232+
233+
functionvaryMatches(key,entry){
234+
if(entry.vary==null){
235+
returntrue
236+
}
237+
238+
for(constheaderNameinentry.vary){
239+
if(Object.hasOwn(entry.vary,headerName)&&!headerValueEquals(key.headers?.[headerName],entry.vary[headerName])){
240+
returnfalse
241+
}
242+
}
243+
244+
returntrue
245+
}
246+
247+
/**
248+
* @param {string|string[]|null|undefined} lhs
249+
* @param {string|string[]|null|undefined} rhs
250+
* @returns {boolean}
251+
*/
252+
functionheaderValueEquals(lhs,rhs){
253+
if(lhs==null&&rhs==null){
254+
returntrue
255+
}
256+
257+
if((lhs==null&&rhs!=null)||
258+
(lhs!=null&&rhs==null)){
259+
returnfalse
260+
}
261+
262+
if(Array.isArray(lhs)&&Array.isArray(rhs)){
263+
if(lhs.length!==rhs.length){
264+
returnfalse
265+
}
266+
267+
for(leti=0;i<lhs.length;i++){
268+
if(lhs[i]!==rhs[i]){
269+
returnfalse
227270
}
271+
}
272+
273+
returntrue
274+
}
228275

229-
returnentry.vary[headerName]===key.headers[headerName]
230-
}))
231-
))
276+
returnlhs===rhs
232277
}
233278

234279
module.exports=MemoryCacheStore

‎deps/undici/src/lib/cache/sqlite-cache-store.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,13 @@ function headerValueEquals (lhs, rhs) {
454454
returnfalse
455455
}
456456

457-
returnlhs.every((x,i)=>x===rhs[i])
457+
for(leti=0;i<lhs.length;i++){
458+
if(lhs[i]!==rhs[i]){
459+
returnfalse
460+
}
461+
}
462+
463+
returntrue
458464
}
459465

460466
returnlhs===rhs

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,13 @@ function processHeader (request, key, val) {
390390
}elseif(typeofval[i]==='object'){
391391
thrownewInvalidArgumentError(`invalid ${key} header`)
392392
}else{
393-
arr.push(`${val[i]}`)
393+
// Coerce primitives (and reject unsafe coercions such as functions
394+
// with a crafted toString/Symbol.toPrimitive).
395+
conststr=`${val[i]}`
396+
if(!isValidHeaderValue(str)){
397+
thrownewInvalidArgumentError(`invalid ${key} header`)
398+
}
399+
arr.push(str)
394400
}
395401
}
396402
val=arr
@@ -401,7 +407,12 @@ function processHeader (request, key, val) {
401407
}elseif(val===null){
402408
val=''
403409
}else{
410+
// Coerce primitives (and reject unsafe coercions such as functions
411+
// with a crafted toString/Symbol.toPrimitive).
404412
val=`${val}`
413+
if(!isValidHeaderValue(val)){
414+
thrownewInvalidArgumentError(`invalid ${key} header`)
415+
}
405416
}
406417

407418
if(headerName==='host'){

‎deps/undici/src/lib/dispatcher/client-h1.js‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const {
1010
RequestContentLengthMismatchError,
1111
ResponseContentLengthMismatchError,
1212
RequestAbortedError,
13+
InvalidArgumentError,
1314
HeadersTimeoutError,
1415
HeadersOverflowError,
1516
SocketError,
@@ -1134,8 +1135,16 @@ function writeH1 (client, request) {
11341135
}
11351136
body=bodyStream.stream
11361137
contentLength=bodyStream.length
1137-
}elseif(util.isBlobLike(body)&&request.contentType==null&&body.type){
1138-
headers.push('content-type',body.type)
1138+
}elseif(util.isBlobLike(body)&&request.contentType==null){
1139+
constcontentType=body.type
1140+
if(contentType){
1141+
constcontentTypeValue=`${contentType}`
1142+
if(!util.isValidHeaderValue(contentTypeValue)){
1143+
util.errorRequest(client,request,newInvalidArgumentError('invalid content-type header'))
1144+
returnfalse
1145+
}
1146+
headers.push('content-type',contentTypeValue)
1147+
}
11391148
}
11401149

11411150
if(body&&typeofbody.read==='function'){

0 commit comments

Comments
 (0)