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

WebUI API: Spaces Encoded as Plus Signs (ie + ) in Query Parameters Are Not Interpreted as Spaces and Instead Become Part of the Parameter #10606

Closed
rmartin16 opened this issue May 9, 2019 · 1 comment · Fixed by #10607

Comments

@rmartin16
Copy link
Contributor

qBittorrent version and Operating System

qBittorrent 4.1.5
Linux (Ubuntu)

If on linux, libtorrent and Qt version

libtorrent 1.1.13.0
Qt 5.12.2

What is the problem

When a space in a query parameter is encoded with a + (plus sign) in a GET request, qBittorrent interprets the plus sign as part of the query parameter value. It appears that query parameters must be percent encoded. Based on what I've read, that makes sense since the plus sign was never actually part of the URL spec. That aside, it definitely happens. Spaces encoded as plus signs in the body of POST (application/x-www-form-urlencoded) requests are interpreted correctly. (Although, the internet suggests this is where the plus sign encoding in URLs came from...)

Case in point, I've been implementing an API client in Python and the requests module will encode spaces in query parameters as plus signs.

I did find the workaround below to ensure query parameters are percent encoded....a bit wonky though.

payload = {'caetgory': 'delete after upload'}
params = urllib.parse.urlencode(payload, quote_via=urllib.parse.quote)
requests.request('get', 'http://localhost:8080/api/v2/torrents/info', cookies={'SID': '...'}, params=params).json()

That said, a POST requests also works around this problem.

What is the expected behavior

Interpret '+' symbols in the query parameters as spaces and %2B as plus signs.

Steps to reproduce

Make the query below:
http://localhost:8080/api/v2/torrents/info?category=delete+after+upload

Extra info(if any)

Endpoints most likely to be affected:
torrents/info
search/categories

@rmartin16 rmartin16 changed the title WebUI API: Only Percent Encoded Spaces are Respected in Query Parameters WebUI API: Spaces Encoded as Plus Signs (ie + ) in Query Parameters Are Not Interpreted as Spaces and Instead Become Part of the Parameter May 9, 2019
Chocobo1 added a commit to Chocobo1/qBittorrent that referenced this issue May 9, 2019
@Chocobo1
Copy link
Member

Chocobo1 commented May 9, 2019

PR #10607 should fix it.

Chocobo1 added a commit to Chocobo1/qBittorrent that referenced this issue May 10, 2019
@qbittorrent qbittorrent locked and limited conversation to collaborators Feb 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants