@@ -468,3 +468,35 @@ test('do not decode redirect body', (t) => {
468468 t . strictSame ( JSON . stringify ( obj ) , await body . text ( ) )
469469 } )
470470} )
471+
472+ test ( 'Receiving non-Latin1 headers' , async ( t ) => {
473+ const ContentDisposition = [
474+ 'inline; filename=rock&roll.png' ,
475+ 'inline; filename="rock\'n\'roll.png"' ,
476+ 'inline; filename="image â\x80\x94 copy (1).png"; filename*=UTF-8\'\'image%20%E2%80%94%20copy%20(1).png' ,
477+ 'inline; filename="_å\x9C\x96ç\x89\x87_ð\x9F\x96¼_image_.png"; filename*=UTF-8\'\'_%E5%9C%96%E7%89%87_%F0%9F%96%BC_image_.png' ,
478+ 'inline; filename="100 % loading&perf.png"; filename*=UTF-8\'\'100%20%25%20loading%26perf.png'
479+ ]
480+
481+ const server = createServer ( ( req , res ) => {
482+ for ( let i = 0 ; i < ContentDisposition . length ; i ++ ) {
483+ res . setHeader ( `Content-Disposition-${ i + 1 } ` , ContentDisposition [ i ] )
484+ }
485+
486+ res . end ( )
487+ } ) . listen ( 0 )
488+
489+ t . teardown ( server . close . bind ( server ) )
490+ await once ( server , 'listening' )
491+
492+ const url = `http://localhost:${ server . address ( ) . port } `
493+ const response = await fetch ( url , { method : 'HEAD' } )
494+ const cdHeaders = [ ...response . headers ]
495+ . filter ( ( [ k ] ) => k . startsWith ( 'content-disposition' ) )
496+ . map ( ( [ , v ] ) => v )
497+ const lengths = cdHeaders . map ( h => h . length )
498+
499+ t . same ( cdHeaders , ContentDisposition )
500+ t . same ( lengths , [ 30 , 34 , 94 , 104 , 90 ] )
501+ t . end ( )
502+ } )
0 commit comments