Skip to content

LinkBuilderSupport.toUri() double-encodes request parameters #1722

Closed
@jochenberger

Description

@jochenberger

We're experiencing a change in behavior regarding path variable expansion.
Consider the following Java code and output:

    public static void main(String[] args) {
        Link l = Link.of("/foo/{data}");
        String data = Base64.getUrlEncoder()
                .encodeToString("Hello".getBytes(StandardCharsets.UTF_8));
        System.out.println("data: " + data);
        System.out.println(l.expand(data).getHref());
    }

Output:

data = SGVsbG8=
/foo/SGVsbG8%3D

In 1.4.0, the "=" is encoded as "%3D", in 1.3.x, it wasn't. This causes issues with Spring Security because a request to the resulting URL is rejected with org.springframework.security.web.firewall.RequestRejectedException: The request was rejected because the URL contained a potentially malicious String "%25".
This is probably related to db1cd5d (#1485).
Are we doing something wrong?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions