[ticket:155]
- unit tests updated to run without any pysqlite installed; pool
test uses a mock DBAPI
+- urls support escaped characters in passwords [ticket:281]
0.2.7
- quoting facilities set up so that database-specific quoting can be
import re
import cgi
+import urllib
import sqlalchemy.exceptions as exceptions
class URL(object):
if self.username is not None:
s += self.username
if self.password is not None:
- s += ':' + self.password
+ s += ':' + urllib.quote_plus(self.password)
s += "@"
if self.host is not None:
s += self.host
else:
query = None
opts = {'username':username,'password':password,'host':host,'port':port,'database':database, 'query':query}
+ if opts['password'] is not None:
+ opts['password'] = urllib.unquote_plus(opts['password'])
return URL(name, **opts)
else:
raise exceptions.ArgumentError("Could not parse rfc1738 URL from string '%s'" % name)
'dbtype:///E:/work/src/LEM/db/hello.db?foo=bar&hoho=lala',
'dbtype://',
'dbtype://username:password@/db',
- 'dbtype:////usr/local/mailman/lists/_xtest@example.com/members.db'
+ 'dbtype:////usr/local/mailman/lists/_xtest@example.com/members.db',
+ 'dbtype://username:apples%2Foranges@hostspec/mydatabase',
):
u = url.make_url(text)
print u, text
print "username=", u.username, "password=", u.password, "database=", u.database, "host=", u.host
assert u.drivername == 'dbtype'
assert u.username == 'username' or u.username is None
- assert u.password == 'password' or u.password is None
+ assert u.password == 'password' or u.password == 'apples/oranges' or u.password is None
assert u.host == 'hostspec' or u.host == '127.0.0.1' or (not u.host)
assert str(u) == text