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

Invalid Malformed URL #3080

Open
nathancassano opened this issue Apr 15, 2019 · 11 comments
Open

Invalid Malformed URL #3080

nathancassano opened this issue Apr 15, 2019 · 11 comments
Labels
Milestone

Comments

@nathancassano
Copy link

The path of a URL contains a colon symbol which is causing the call to fail.

Using version com.squareup.retrofit2:retrofit:2.5.0

Code:

public interface ClientApi {
    @PUT("user:email={email}/login")
    Call<ResponseBody> login(@Path("email") String email, @Body String pass);

    @PUT("./user:email={email}/login")
    Call<ResponseBody> loginRelative(@Path("email") String email, @Body String pass);
...

Regular path
Stack trace:

Caused by: java.lang.IllegalArgumentException: Malformed URL. Base: https://test.com/restapi/, Relative: user:email=me@test.com/login
        at retrofit2.RequestBuilder.get(RequestBuilder.java:221)
        at retrofit2.RequestFactory.create(RequestFactory.java:111)
        at retrofit2.OkHttpCall.createRawCall(OkHttpCall.java:190)
        at retrofit2.OkHttpCall.execute(OkHttpCall.java:173)
        at Service.login(Service.java:38)

Think the code needs to treat the relative portion of the URL like an absolute URL when parsing.

Relative path
Using a retaliative path annotation ./ does not solve this issue.
Stack trace:

Caused by: java.lang.IllegalArgumentException: @Path parameters shouldn't perform path traversal ('.' or '..'):
        at retrofit2.RequestBuilder.addPathParam(RequestBuilder.java:113)
        at retrofit2.ParameterHandler$Path.apply(ParameterHandler.java:99)
        at retrofit2.RequestFactory.create(RequestFactory.java:108)
        at retrofit2.OkHttpCall.createRawCall(OkHttpCall.java:190)
        at retrofit2.OkHttpCall.execute(OkHttpCall.java:173)

Bug report unit test
https://gist.github.com/nathancassano/f675e2fd1c64d4b6002afea37bf5fee4

@JakeWharton
Copy link
Collaborator

Yeah this should be allowed.

cc @swankjesse

@JakeWharton JakeWharton added this to the 2.6 milestone Apr 16, 2019
@sangeetha5491
Copy link

can I work on this issue?

@swankjesse
Copy link
Member

No, we need to study to learn what the correct behavior is.

@ghost
Copy link

ghost commented Jan 7, 2020

Is there any news about this issue? This problem causes a version lock to 2.4.0.

anotherdev added a commit to anotherdev/firebase-auth-rest that referenced this issue Mar 19, 2020
@bio007
Copy link

bio007 commented Apr 15, 2021

Hi, any update on this?

@roshanrajaratnam
Copy link

Hi any update on this? colon in a path variable seem to be encoded as %253A instead of just %3A.

@yagyank
Copy link

yagyank commented Nov 27, 2021

Hey can I pick this issue?

@guyferguson
Copy link

Still an isue....

@sagar392
Copy link

sagar392 commented May 10, 2023

The following interface doesn't even exists in the repository

@guyferguson
Copy link

I am using the latest retrofit version and this issue persists. Can you specify the specific Interface you say does not exist, or would it be better for me to find teh line in retrofit that generates the error msg?

@richardbn
Copy link

Still an isue....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants