diff --git a/web/db.py b/web/db.py
index a51fa7a..66b7cf1 100644
--- a/web/db.py
+++ b/web/db.py
@@ -1139,13 +1139,23 @@ def dburl2dict(url):
"""
+ import re
dbn, rest = url.split('://', 1)
user, rest = rest.split(':', 1)
- pw, rest = rest.split('@', 1)
+ user = re.sub("""['"]""", '', user)
+ if rest.startswith('"'):
+ pw, rest = rest.split('"', 2)[1:]
+ rest = rest.split('@', 1)[1]
+ elif rest.startswith("'"):
+ pw, rest = rest.split("'", 2)[1:]
+ rest = rest.split('@', 1)[1]
+ else:
+ pw, rest = rest.split('@', 1)
+
host, rest = rest.split(':', 1)
port, rest = rest.split('/', 1)
db = rest
- return dict(dbn=dbn, user=user, pw=pw, db=db, host=host)
+ return dict(dbn=dbn, user=user, pw=pw, db=db, host=host, port=port)
_databases = {}
def database(dburl=None, **params):