jazzband / dj-database-url

Use Database URLs in your Django Application.
https://pypi.org/project/dj-database-url/
BSD 3-Clause "New" or "Revised" License
1.48k stars 205 forks source link

URL-decode whole hostname when appropriate #67

Closed jdp closed 7 years ago

jdp commented 8 years ago

Adds support for other special characters in UNIX socket path names, like the colons in Cloud SQL paths.

See also: https://github.com/kennethreitz/dj-database-url/issues/66

kennethreitz commented 8 years ago

This seems harmless....

kennethreitz commented 8 years ago

If anyone else can comment on this, would be much appreciated.

kennethreitz commented 8 years ago

If there's anything I've learned from Requests, it's never touch URL encoding unless you know you need to.

benwilber commented 8 years ago

This patch looks like the correct thing to do.

jdp commented 8 years ago

Percent-encoding is allowed in URI hosts per RFC 3986, provided that the host is intended to be interpreted as UTF-8:

reg-name = *( unreserved / pct-encoded / sub-delims ) ... URI producing applications must not use percent-encoding in host unless it is used to represent a UTF-8 character sequence.

The newer URL Standard tightens up the character restrictions in hosts in URL's though. Hosts can still be percent-encoded, but fail to parse if any restricted characters are still present after decoding:

If asciiDomain contains U+0000, U+0009, U+000A, U+000D, U+0020, "#", "%", "/", ":", "?", "@", "[", "\", or "]", syntax violation, return failure.

I wouldn't be against changing the URL format to cloudsql:/cloudsql/project-id:instance-id?username=&password=&database= or something.

kennethreitz commented 7 years ago

needs a rebase!