Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spaces in Form Submit Query Parameters are not decoded properly #221

Open
2 tasks done
jaecktec opened this issue Jun 17, 2024 · 2 comments
Open
2 tasks done

spaces in Form Submit Query Parameters are not decoded properly #221

jaecktec opened this issue Jun 17, 2024 · 2 comments

Comments

@jaecktec
Copy link

jaecktec commented Jun 17, 2024

Prerequisites

  • I have written a descriptive issue title
  • 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

@adrai
Copy link
Member

adrai commented Jun 17, 2024

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?

@jaecktec
Copy link
Author

jaecktec commented Jun 18, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants