Skip to content

Behavior of URL encoding for query parameter changed #1189

@bushwakko

Description

@bushwakko

After updating to newest version (10.7.4) the way query parameters are encoded seems to have changed. I am using JAXRSContract and an interface like this (PS: I didn't design this API, and would never use GET to create an entity):

@GET @Path("/method") PaymentMethodResponse createTransaction(@QueryParam("redirect_url") final String redirectUrl);

Doing client.createTransaction("http://test") would usually encode this as: http%3A%2F%2Ftest
but would now end up being: http%3A//test (the reason being that decodeSlash would both be set default to true, and be invoked for query-parameters.

This behavior also applies when using the @RequestLine annotations, but can be solved by setting decodeSlash = false.

Since there is no way to set "decodeSlash" via the jaxrs-annotations or to configure the JAXRSContract to have it default "false", a very dirty fix for us was to do the following:
`
private static class NoDecodeSlashJAXRSContract extends JAXRSContract {
public NoDecodeSlashJAXRSContract() {
super();
}

    @Override
    protected MethodMetadata parseAndValidateMetadata(Class<?> targetType, Method method) {
        final MethodMetadata methodMetadata = super.parseAndValidateMetadata(targetType, method);
        final RequestTemplate template = methodMetadata.template();
        template.uri("", true);
        template.decodeSlash(false);
        return methodMetadata;
    }
}

`

The template.uri is set here to not get NPE on missing uri when setting decodeSlash via the method, and the decodeSlash is then set to false. This brings back the previous behavior.

I suspect this is somehow a introduced when this code path was recently rewritten.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions