Skip to content

Query parameter encoding #1584

@tomsmalley

Description

@tomsmalley

In v0.18, query parameters were converted with toQueryParam and later encoded as part of renderQuery.

In v0.19, this was changed so that conversion and encoding of query parameters is done at once by toEncodedUrlPiece, and the parts are joined without doing extra encoding.

At first glance this seems like a good change since it allows more control over how encoding is done, but there's a subtlety:

The default implementation of toEncodedUrlPiece uses encodePathSegmentsRelative, which uses urlEncodeBuilder but with the first argument set to False: i.e., denoting the input as a path element, not a query string.

So, when using servant "end to end" on the same API with String or Text query params, the server no longer gets what the client sent if any of the extra query special characters are present &=+$,. I think this change wasn't intentional, thus this ticket.

I suppose a more correct change would be to add toEncodedQuery or something to the class, but that's a much larger change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions