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

Query params will be encoded twice in newest Version 10.7.2 #1156

Closed
ghost opened this issue Jan 13, 2020 · 3 comments · Fixed by #1160
Closed

Query params will be encoded twice in newest Version 10.7.2 #1156

ghost opened this issue Jan 13, 2020 · 3 comments · Fixed by #1160
Labels
feedback provided Feedback has been provided to the author
Milestone

Comments

@ghost
Copy link

ghost commented Jan 13, 2020

After the release of version 10.7.2, values of query params in the expression will be encoded twice.
Following URL will be generated when I provide the string :§$%&/()= as parameter value:
https://www.abc.com/foo?bar=%253A%25C2%25A7%2524%2525%2526%2F%2528%2529%253D
When I decode the URL I get following result:
https://www.abc.com/foo?bar=%3A%C2%A7%24%25%26/%28%29%3D
And exactly this result shows a URL that is encoded, so therefore when I decode the result again, I get following string:
https://www.abc.com/foo?bar=:§$%&/()=

Unfortunatly, changing the HTTP client did not help. Am I the only one who got this problem?

@kdavisk6
Copy link
Member

To better help and understand your issue, can you please provide your Feign interface definition and a simple working example?

@kdavisk6 kdavisk6 added the feedback provided Feedback has been provided to the author label Jan 14, 2020
@thole
Copy link

thole commented Jan 14, 2020

I hope this demo helps.
Many thanks

public class Demo {
    public interface Echo {
        @RequestLine("GET /get?someUrl={value}")
        String sampleCall(@Param("value") String value);
    }

    public static void main(String[] args){
        Echo echo = Feign.builder()
                .logLevel(Logger.Level.FULL)
                .logger(new Logger.ErrorLogger())
                .target(Echo.class, "https://postman-echo.com");

        System.out.println(echo.sampleCall("http://www.google.de"));
    }
}

generated url in 10.7.2 : https://postman-echo.com/get?someUrl=http%253A%2F%2Fwww.google.de
generated url in 10.7.0 : https://postman-echo.com/get?someUrl=http:%2F%2Fwww.google.de
generated url in 10.1.0 : https://postman-echo.com/get?someUrl=http%3A%2F%2Fwww.google.de

kdavisk6 added a commit to kdavisk6/feign that referenced this issue Jan 17, 2020
Fixes OpenFeign#1156

Collection Format was encoding query string values unnecessarily
due to changes introduced in OpenFeign#1138 and OpenFeign#1139 that encode template
values before appending them to the query string.

In addition, `decodeSlash` flags that were accidentally removed,
have been restored in QueryTemplate.
@kdavisk6
Copy link
Member

I found the issue. CollectionFormat was encoding values again when it did not need to be. In addition, decodeSlash was being ignored in query string values. #1160 restores decodeSlash support and corrects the double encoding.

The example above after this change will now be:

 public interface Echo {
        @RequestLine("GET /get?someUrl={value}")
        String sampleCall(@Param("value") String value);
}
https://postman-echo.com/get?someUrl=http%3A//www.google.de
public interface Echo {
        @RequestLine("GET /get?someUrl={value}", decodeSlash=false)
        String sampleCall(@Param("value") String value);
}
https://postman-echo.com/get?someUrl=http%3A%2F%2Fwww.google.de

kdavisk6 added a commit to kdavisk6/feign that referenced this issue Jan 18, 2020
Fixes OpenFeign#1156

Collection Format was encoding query string values unnecessarily
due to changes introduced in OpenFeign#1138 and OpenFeign#1139 that encode template
values before appending them to the query string.

In addition, `decodeSlash` flags that were accidentally removed,
have been restored in QueryTemplate.
kdavisk6 added a commit that referenced this issue Jan 18, 2020
Fixes #1156

Collection Format was encoding query string values unnecessarily
due to changes introduced in #1138 and #1139 that encode template
values before appending them to the query string.

In addition, `decodeSlash` flags that were accidentally removed,
have been restored in QueryTemplate.

* Restoring decodeSlash in QueryTemplate

* Correcting Readme with regards to decodeSlash usage
@kdavisk6 kdavisk6 added this to the 10.8 milestone Jan 18, 2020
velo pushed a commit that referenced this issue Oct 7, 2024
Fixes #1156

Collection Format was encoding query string values unnecessarily
due to changes introduced in #1138 and #1139 that encode template
values before appending them to the query string.

In addition, `decodeSlash` flags that were accidentally removed,
have been restored in QueryTemplate.

* Restoring decodeSlash in QueryTemplate

* Correcting Readme with regards to decodeSlash usage
velo pushed a commit that referenced this issue Oct 8, 2024
Fixes #1156

Collection Format was encoding query string values unnecessarily
due to changes introduced in #1138 and #1139 that encode template
values before appending them to the query string.

In addition, `decodeSlash` flags that were accidentally removed,
have been restored in QueryTemplate.

* Restoring decodeSlash in QueryTemplate

* Correcting Readme with regards to decodeSlash usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback provided Feedback has been provided to the author
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants