Skip to content

Unexpected exception in UriComponentsBuilder with a valid URI. #32815

Closed as not planned
@victorherraiz

Description

@victorherraiz

Query string parameters with equals in the value throw and exception in build method:

    @Test
    public void equals_in_query_string_value() {
        var str = "https://localhost:8080/callback?param1=a%20b&param2=1=2";
        var uri = URI.create(str);
        var actual = UriComponentsBuilder.fromUri(uri)
            .build(true)
            .toUri();
        assertEquals(uri, actual);
    }

Exception:

java.lang.IllegalArgumentException: Invalid character '=' for QUERY_PARAM in "1=2"

I use true because the source is already a valid URI and I do not want a doble escape in the param1.

I did not find anything in any standard or convention that says that this character is forbidden, I tried different implementations and they worked as espected: URLSearchParams in any browser, node queryparams, etc.

Expected behaviour:

  • Both URIs in the test should be equal.
  • No exception should be thrown.
  • param2 equals 1=2

References:

URL (Web API) example:

new URL('https://localhost:8080/callback?param1=a%20b&param2=1=2').searchParams
URLSearchParams { 'param1' => 'a b', 'param2' => '1=2' }

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webIssues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently apply

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions