damnhandy / Handy-URI-Templates

A Java URI Template processor implementing RFC6570

Home Page:https://damnhandy.github.io/Handy-URI-Templates/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

encoding of '`' and '"' in query parameters

faisalferoz opened this issue · comments

as per the unreserved characters, back-tick ``` and inverted quote " both don't fall into the unreserved set but these are not encoded when using UriTemplate.

Do you happen to have a test case handy? If so, I'll get it added to the uritemplate-test suite, which is where this project derives the majority of it's tests from.

{
  "Level 1 Examples" : 
  {
    "level": 1,
    "variables": {
       "backtick"   : "`",
       "cap" : "^",
       "invertedquote": "\""
     },
     "testcases" : [
        ["{backtick}", "%60"],
        ["{cap}", "%5E"],
        ["{invertedquote}", "%22"]
     ]
  }
}

Any plans to release this fix? I presume it would also work in path variables? I would expect in this example that the backtick is %60 encoded and thus parse as a URI, just as the greaterThan example is.

@Test
public void testBacktick() throws URISyntaxException {
    String url = UriTemplate.fromTemplate("http://example.com/{var}").set("var", "`").expand();
    URI uri = new URI(url);
}

@Test
public void testGreaterThan() throws URISyntaxException {
    String url = UriTemplate.fromTemplate("http://example.com/{var}").set("var", ">").expand();
    URI uri = new URI(url);
}

I have tested with 2.0.3-SNAPSHOT and it still issue is still there.