Skip to content

JerseyHandlerFilter breaks query string encoding #140

Closed
@sedovalx

Description

@sedovalx
  • Framework version: 1.0
  • Implementations: Jersey

Scenario

When the JerseyHandlerFilter handles requests that contain encoded + signs in query parameters it breaks the encoding. As a result, such a query parameter retrieved via @QueryParam in an endpoint is wrongly decoded. As an example, the parameter param=p%2Fz%2B3 of the original request is decoded as param=p/z 3 via the @QueryParam.

Though, the same query parameter that is retrieved as HttpServletRequest#getParameter is properly decoded. The difference is that the serverless contained gets the query parameter directly from the AwsProxyRequest without intermediate decoding/encoding actions.

Expected behavior

Original query parameter param=p%2Fz%2B3 of a request should be retrieved as follows:

  • @QueryParam("param") String param -> "p/z+3"
  • @QueryParam("param") @Encoded String param -> "p%2Fz%2B3"
  • request.getParameter("param") -> "p/z+3"

Actual behavior

  • @QueryParam("param") String param -> "p/z 3"
  • @QueryParam("param") @Encoded String param -> "p%2Fz+3"
  • request.getParameter("param") -> "p/z+3"

Steps to reproduce

Create an endpoint

@GET
@Path("/test")
public Response getAll(@QueryParam("param") String param) {
  ...
}

Run the code in AWS Lambda or locally in SAM Local. Then, try to GET /test?param=p%2Fz%2B3

Full log output

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions