Skip to content

UriTemplate expansion reserved ("+") and fragment("#") should not encode already percent encoded parts #2107

@alexander-asenov

Description

@alexander-asenov

According to RFC 6570 Section 3.2.1: reserved ("+") and fragment ("#") expansions allow the set of characters in the union of ( unreserved / reserved / pct-encoded ) to be passed through without pct-encoding, whereas all other expression types allow only unreserved characters to be passed through without pct-encoding.

But currently pct-encoded characters are being re-encoded. Meaning that {+var} and {#var} should not re-encode already pct-encoded triplets, but currently the implementation does that:

Code example

    @Test
    void textUriTemplate_shouldNotEncodeAlreadyPercentEncodedTriplets() {
        String template = "{+var}";
        Map<String, Object> variables = Map.of("var", "admin%2F");

        String result = UriTemplate.expand(template, variables, false);

        // Expecting the result to be "admin%2F" without encoding
        Assertions.assertEquals("admin%2F", result, "The encoded character should not be changed.");
    }
Expected : admin%2F
Actual   : admin%252F

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions