From 5376b08110a646cbc3aa11410b1bfaeafad81e45 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Tue, 7 May 2024 10:57:01 +0200 Subject: [PATCH] Fix double-decode on presigm param This was only passing the tests because we incorrecly were double-encoding the presigned params too. --- src/lambda-handler.ts | 2 +- tests/test-private-upload.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lambda-handler.ts b/src/lambda-handler.ts index 71fa18d..29f9c3a 100644 --- a/src/lambda-handler.ts +++ b/src/lambda-handler.ts @@ -33,7 +33,7 @@ const streamify_handler: StreamifyHandler = async ( event, response ) => { // If there is a presign param, we need to decode it and add it to the args. This is to provide a secondary way to pass pre-sign params, // as using them in a Lambda function URL invocation will trigger a Lambda error. if ( args.presign ) { - const presignArgs = new URLSearchParams( decodeURIComponent( args.presign ) ); + const presignArgs = new URLSearchParams( args.presign ); for ( const [ key, value ] of presignArgs.entries() ) { args[ key as keyof Args ] = value; } diff --git a/tests/test-private-upload.ts b/tests/test-private-upload.ts index e7e6bf1..b9d33c8 100644 --- a/tests/test-private-upload.ts +++ b/tests/test-private-upload.ts @@ -95,7 +95,7 @@ test( 'Test get private upload with presign params', async () => { 'headers': { }, 'queryStringParameters': { - presign: encodeURIComponent( new URLSearchParams( presignParams ).toString() ), + presign: new URLSearchParams( presignParams ).toString(), }, 'isBase64Encoded': false, };