Description
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