Skip to content

Double decoding of query parameters when creating Location #12354

Closed

Description

@ggecy

When I open an URL with url encoded query parameters where a parameters contains a "+" symbol, the query parameter is incorrectly decoded twice and the "+" is removed from parameter value. This happens in com.vaadin.flow.router.Location#Location(java.lang.String) which calls the com.vaadin.flow.router.LocationUtil#parseQueryParameters where query string is first extracted query = new java.net.URI(location).getQuery(); - this decodes the url encoded string for the first time, the string at this point is correct and "+" symbol gets decoded from "%2B". Next the QueryParameters.fromString(query) is called which calls com.vaadin.flow.router.QueryParameters#makeQueryParamList and this decodes the string again using value = URLDecoder.decode(value, "utf-8"); - this removed the "+" symbol from the already decoded string and the parameter value is incorrect.

E.g. the encoded parameter value someValue1%2BsomeValue2 which should be decoded as someValue1+someValue2 gets decoded as someValue1 someValue2 instead which is wrong.

Versions:

- Vaadin / Flow version: 14.7.5 / 2.7.4
- Java version: 11

Activity

  1. added a commit that references this issue on Nov 24, 2021
    b98139b
  2. self-assigned this
    on Nov 26, 2021
  3. added a commit that references this issue on Nov 29, 2021
    94766fa
  4. added 7 commits that reference this issue on Nov 29, 2021
    0cc7787
    1b59401
    63da46e
    92eaf82
    567bd21
    3d34020
    8f0445c
  5. added a commit that references this issue on Nov 29, 2021
    0863915
  6. vaadin-bot commented on Dec 7, 2021

    @vaadin-bot
    Collaborator

    This ticket/PR has been released with platform 14.8.0.beta1 and is also targeting the upcoming stable 14.8.0 version.

  7. vaadin-bot commented on Dec 7, 2021

    @vaadin-bot
    Collaborator

    This ticket/PR has been released with platform 14.7.8.

  8. vaadin-bot commented on Dec 9, 2021

    @vaadin-bot
    Collaborator

    This ticket/PR has been released with platform 22.0.1.

  9. mlopezFC commented on Jan 28, 2022

    @mlopezFC

    This issue was solved by just handling the plus sign "+" special case, but something similar happens with the "%" character.
    Is it possible to solve the underlying issue (avoid double decoding) instead of handling specific character conversion issues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions