djangid / rest-assured

Automatically exported from code.google.com/p/rest-assured
0 stars 0 forks source link

Escape "illegal" characters in parameters #188

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Suppose I use RestAssured like this:

<code>
RestAssured
   .given().pathParam("dummy", "begin?everything from here will be ignored")
   .expect().statusCode(200)
   .when().get("/some/path/{dummy}")
</code>

What is the expected output? What do you see instead?

I expect the generated http URL to end up with 

"/some/path/begin%3Feverything%20from%20here%20will%20be%20ignored"

but the '?' is not escaped - and since it means something to the HTTP URL spec 
(separation of the query and the parameters), the remaining part after ? is not 
considered part of the query and thus ignored.

It event produces even worse results if I add params to the get call (since 
there will be two '?' in the URL...

What version of the product are you using? On what operating system?

RestAssured 1.6.1

Thank you in advance!

Original issue reported on code.google.com by alexandr...@gmail.com on 13 Aug 2012 at 1:35

GoogleCodeExporter commented 8 years ago
I thought this would work already but I suppose not :) If you're desperate for 
a work-around you can try to URL encode the string yourself and disable URL 
encoding in REST Assured. Thanks for reporting! 

Original comment by johan.ha...@gmail.com on 15 Aug 2012 at 6:19

GoogleCodeExporter commented 8 years ago
When I come to think of it I think I've solved this in a different branch once. 
I discarded this branch because Jersey URL decoded the URL before it reached 
the endpoint. Meaning that if you included a ? in the path it would still be 
interpreted as a "standard" question mark and things would go wrong. It may be 
a bug in Jersey but I thought maybe this was expected behavior. You can try it 
out if you build REST Assured (without tests) from the "slash_in_path" branch.

Original comment by johan.ha...@gmail.com on 23 Aug 2012 at 5:45

GoogleCodeExporter commented 8 years ago
Ok so I've look into this a little bit and the reason is the ? mark. Other 
chars will be url encoded. The reason is that ? is interpreted as the beginning 
of the query params section.

Original comment by johan.ha...@gmail.com on 11 Oct 2012 at 7:21

GoogleCodeExporter commented 8 years ago
This ought to be fixed in master now. Try out version 1.8.2-SNAPSHOT after 
having added on the following repo:

<repositories>
        <repository>
            <id>sonatype</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
            <snapshots />
        </repository>
</repositories>

Original comment by johan.ha...@gmail.com on 19 Nov 2013 at 6:58