Opened 7 years ago
Closed 7 years ago
#29972 closed Bug (invalid)
Django QueryDict replace plus "+" by space in query string
| Reported by: | Vuong Hoang | Owned by: | nobody |
|---|---|---|---|
| Component: | HTTP handling | Version: | 2.1 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
When query string contains plus sign "+", e.g GET /api/tasks/?start_time=2018-11-21T11:47:15+07:00
I expect that on server:
request.GET['start_time'] == '2018-11-21T11:47:15+07:00'
But actual:
request.GET['start_time'] == '2018-11-21T11:47:15 07:00'
make the server validation failed (Invalid ISO8061 datetime string in my case)
After debugging, I find out QueryDict using limited_parse_qsl() function, that replace + with space
https://github.com/django/django/blob/master/django/utils/http.py#L433
Is this behavior a bug or some feature?
Thank you
This behaviour is a feature, not a bug.
The plus sign is a reserved character, if you want to pass a plus sign you will need to encode it as
%2B.For more details on encoding query parameters see https://en.wikipedia.org/wiki/Percent-encoding
Have a great day!