Skip to content

UriTemplate reserved expansion should not escape reserved characters #1838

@cHengstler

Description

@cHengstler

UriTemplate.expand should not escape reserved characters in values for reserved expansion (e.g., templates of the form "{+var}").

According to section of 3.2.3 Reserved Expansion: {+var}, reserved character should not be escaped.
Level 2 templates add the plus ("+") operator, for expansion of values that are allowed to include reserved URI characters (Section 1.5).

Example code:

    @Test
    public void testExpandTemplates_reservedExpansion_shouldNotEscapeReservedCharSet() {

        var genDelims = ":/?#[]@";
        var subDelims = "!$&'()*+,;=";
        var reservedSet = genDelims+subDelims;

        var requestMap = Map.of("var", reservedSet);

        assertThat(UriTemplate.expand("{+var}", requestMap, false), is(reservedSet));

        // Expected: is ":/?#[]@!$&'()*+,;="
        //     but: was ":/?%23%5B%5D@!$&'()*+,;="
        
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p3Desirable enhancement or fix. May not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions