mirror of
https://github.com/jazzband/dj-database-url.git
synced 2026-03-16 22:20:24 +00:00
Merge pull request #45 from tomwys/special_characters
Support special characters in user, password and name fields.
This commit is contained in:
commit
19dc4ab90a
2 changed files with 14 additions and 3 deletions
|
|
@ -81,9 +81,9 @@ def parse(url, engine=None, conn_max_age=0):
|
|||
|
||||
# Update with environment configuration.
|
||||
config.update({
|
||||
'NAME': path or '',
|
||||
'USER': url.username or '',
|
||||
'PASSWORD': url.password or '',
|
||||
'NAME': urlparse.unquote(path or ''),
|
||||
'USER': urlparse.unquote(url.username or ''),
|
||||
'PASSWORD': urlparse.unquote(url.password or ''),
|
||||
'HOST': hostname,
|
||||
'PORT': url.port or '',
|
||||
'CONN_MAX_AGE': conn_max_age,
|
||||
|
|
|
|||
|
|
@ -34,6 +34,17 @@ class DatabaseTestSuite(unittest.TestCase):
|
|||
assert url['PASSWORD'] == ''
|
||||
assert url['PORT'] == ''
|
||||
|
||||
def test_postgres_parsing_with_special_characters(self):
|
||||
url = 'postgres://%23user:%23password@ec2-107-21-253-135.compute-1.amazonaws.com:5431/%23database'
|
||||
url = dj_database_url.parse(url)
|
||||
|
||||
assert url['ENGINE'] == 'django.db.backends.postgresql_psycopg2'
|
||||
assert url['NAME'] == '#database'
|
||||
assert url['HOST'] == 'ec2-107-21-253-135.compute-1.amazonaws.com'
|
||||
assert url['USER'] == '#user'
|
||||
assert url['PASSWORD'] == '#password'
|
||||
assert url['PORT'] == 5431
|
||||
|
||||
def test_postgis_parsing(self):
|
||||
url = 'postgis://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn'
|
||||
url = dj_database_url.parse(url)
|
||||
|
|
|
|||
Loading…
Reference in a new issue