feign icon indicating copy to clipboard operation
feign copied to clipboard

About character escape

Open paimonx opened this issue 3 years ago • 2 comments

Characters Are Not Escaped !

a example:

The provider `

@PostMapping("find")
public String find(@RequestParam(name = "name",required = true) String name,
                   @RequestParam(name = "text",required = true) String text){


    return "hello";
}

`

The consumer

`

@Autowired
UserFeign userFeign;

@Test
void contextLoads() {
    String name = "12%2601";
    String text ="&";
    String s = userFeign.find(name, text);
}

`

result:

img

environment: java version 1.8.0_202; Spring boot 2.3.7.RELEASE; feign-core 10.10.1

This Result Is Different From What I Expected , I Think name should Be “12%2601”. debug, i Noticed feign.RequestTemplate#resolve append uri = “/find?name=12%2601&text=%26” ,% is Not Escaped, resulting In Provider Resolution Failure.

img_2

I think they should all be escaped, or Allow Developers To Modify It.

Sorry, my English is very weak!!!

paimonx avatar Feb 17 '22 12:02 paimonx

Is there a way to escape them all?

paimonx avatar Feb 17 '22 12:02 paimonx

The end result on the URI is PCT-encoded as per the URI Template specification: https://datatracker.ietf.org/doc/html/rfc6570

Values such as % and & are reserved and will not be encoded again. I recommend that you read more on percent encoding: https://en.wikipedia.org/wiki/Percent-encoding, to see if your assumptions are correct.

kdavisk6 avatar Mar 24 '22 14:03 kdavisk6