Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feign 10.1, '+' in query param is not encoded #895

Closed
grusell opened this issue Feb 4, 2019 · 2 comments
Closed

Feign 10.1, '+' in query param is not encoded #895

grusell opened this issue Feb 4, 2019 · 2 comments

Comments

@grusell
Copy link

grusell commented Feb 4, 2019

I would expect a '+' inside a query parameter value to be encoded to '%2B'. With feign 10.1, it seems the '+' is left untouched when the param is encoded.

@cecchisandrone
Copy link

cecchisandrone commented Feb 4, 2019

I noticed the same while migrating from 9.3.1 to 10.0.1.

In particular the suspect code is in UriUtils:

private static String urlEncode(String value, Charset charset) {
    try {
      String encoded = URLEncoder.encode(value, charset.toString());

      /*
       * url encoding is not equivalent to URI encoding, there are few differences, namely dealing
       * with spaces, !, ', (, ), and ~ characters. we will need to manually process those values.
       */
      return encoded.replaceAll("\\+", "%20")
          .replaceAll("\\%21", "!")
          .replaceAll("\\%27", "'")
          .replaceAll("\\%28", "(")
          .replaceAll("\\%29", ")")
          .replaceAll("\\%7E", "~")
          .replaceAll("\\%2B", "+");

    } catch (UnsupportedEncodingException uee) {
      /* since the encoding is not supported, return the original value */
      return value;
    }

For example the value +asd for a path parameter is first encoded to %2Basd and after restored to +asd.

I think this must considered duplicate of #879

@kdavisk6
Copy link
Member

kdavisk6 commented Feb 6, 2019

It is a duplicate. It has been fixed via #882

@kdavisk6 kdavisk6 closed this as completed Feb 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants