aws-lambda-fastify icon indicating copy to clipboard operation
aws-lambda-fastify copied to clipboard

spaces in Form Submit Query Parameters are not decoded properly

Open jaecktec opened this issue 1 year ago • 2 comments

Prerequisites

  • [X] I have written a descriptive issue title
  • [X] I have searched existing issues to ensure the bug has not already been reported

Fastify version

4.25.2

Plugin version

3.5.0

Node.js version

20

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

Description

When a form-submit with action 'GET' sends a query the query will be encoded as URLSearchParams, meaning spaces = + (not %20)

so adjusting this test will fail:

Link to code that reproduces the bug


test('GET with encoded query values', async (t) => {
  t.plan(2)

  const app = fastify()
  app.get('/test', async (request, reply) => {
    reply.send(request.query)
  })
  const proxy = awsLambdaFastify(app)

  const ret = await proxy({
    requestContext: { elb: { targetGroupArn: 'xxx' } },
    httpMethod: 'GET',
    path: '/test',
    queryStringParameters: {
      'q%24': 'foo+%3Fbar'
    }
  })
  t.equal(ret.statusCode, 200)
  t.equal(ret.body, '{"q$":"foo ?bar"}')
})

Expected Behavior

The query parameters should be parsed using 'querystring' to mimic the behaviour of the 'normal' fastify runtime

jaecktec avatar Jun 17 '24 14:06 jaecktec

Can you check how the original aws lambda event looks like and then open a new PR by creating a dedicated test for this and providing the appropriate fix?

adrai avatar Jun 17 '24 17:06 adrai

looks the same, I've checked (this is how I've noticed) a + will not be transformed to a space.

jaecktec avatar Jun 18 '24 07:06 jaecktec

Is this still relevant? Have you prepared a PR to address this?

adrai avatar Jan 22 '25 14:01 adrai

sorry no - I've switched to hono for this use-case

jaecktec avatar Jan 22 '25 16:01 jaecktec