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?
To better help and understand your issue, can you please provide your Feign interface definition and a simple working example?
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
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
Most helpful comment
I found the issue.
CollectionFormatwas encoding values again when it did not need to be. In addition,decodeSlashwas being ignored in query string values. #1160 restoresdecodeSlashsupport and corrects the double encoding.The example above after this change will now be: