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

Equivalent of path-as-is option in curl #895

Closed
exploide opened this issue Apr 13, 2020 · 5 comments
Closed

Equivalent of path-as-is option in curl #895

exploide opened this issue Apr 13, 2020 · 5 comments
Labels
enhancement New feature or enhancement

Comments

@exploide
Copy link
Contributor

In curl there is the --path-as-is option:

Tell curl to not handle sequences of /../ or /./ in the given URL path. Normally curl will squash or merge them according to standards but with this option set you tell it not to do that.

Currently, httpie does not send paths like /../../../../../ to the server but resolves and removes them locally.

Sending such sequences can be useful during security testing, e.g. checking directory traversal vulnerabilities.

I would like to request a similar option as curl's --path-as-is.

@jkbrzt jkbrzt added enhancement New feature or enhancement blocked by upstream The issue is in a dependency. We are waiting for the upstream library to lay the groundwork. labels Apr 13, 2020
@jkbrzt
Copy link
Member

jkbrzt commented Apr 13, 2020

The dot segment removal is automatically applied by the upstream urllib3 library in its parse_url() implementation. Which is called from requests’s PreparedRequest.prepare():

Currently, neither library provides a way to disable the normalisation, sadly.

urllib3==1.25.8
requests==2.23.0


$ http --offline example.org/foo/../bar/
GET /bar/ HTTP/1.1

@exploide
Copy link
Contributor Author

Good to know.

In the meantime, one can partially workaround this by manually URL-encoding / as %2f if needed.

@exploide
Copy link
Contributor Author

Actually, this was already requested for the requests library in psf/requests#5289

The issue contains a solution approved by a maintainer.

@jkbrzt jkbrzt closed this as completed in 684a470 Apr 13, 2020
@jkbrzt
Copy link
Member

jkbrzt commented Apr 13, 2020

@exploide the linked issue includes a comment with a decent workaround, so I’ve just pushed support for --path-as-is to master (will be shipped with a future > v2.0.0 release).

$ http  --path-as-is  --offline  example.org/../../etc/password
GET /../../etc/password HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: example.org
User-Agent: HTTPie/2.1.0-dev

@jkbrzt jkbrzt removed the blocked by upstream The issue is in a dependency. We are waiting for the upstream library to lay the groundwork. label Apr 13, 2020
@exploide
Copy link
Contributor Author

Awesome. That was fast. Thanks! 👍

jkbrzt added a commit that referenced this issue Apr 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants