=== modified file 'gluon/sql.py'
--- gluon/sql.py	2010-08-28 14:32:34 +0000
+++ gluon/sql.py	2010-12-05 00:38:15 +0000
@@ -43,6 +43,7 @@
 from utils import md5_hash, web2py_uuid
 from serializers import json
 from http import HTTP
+from urllib import unquote_plus
 
 logger = logging.getLogger("web2py.sql")
 
@@ -955,21 +956,21 @@
             if not m:
                 raise SyntaxError, \
                     "Invalid URI string in SQLDB: %s" % self._uri
-            user = m.group('user')
+            user = unquote_plus(m.group('user'))
             if not user:
                 raise SyntaxError, 'User required'
-            passwd = m.group('passwd')
+            passwd = unquote_plus(m.group('passwd'))
             if not passwd:
                 passwd = ''
-            host = m.group('host')
+            host = unquote_plus(m.group('host'))
             if not host:
                 raise SyntaxError, 'Host name required'
-            db = m.group('db')
+            db = unquote_plus(m.group('db'))
             if not db:
                 raise SyntaxError, 'Database name required'
             port = m.group('port') or '3306'
 
-            charset = m.group('charset') or 'utf8'
+            charset = unquote_plus(m.group('charset') or 'utf8')
 
             self._pool_connection(lambda : MySQLdb.Connection(
                     db=db,
@@ -990,16 +991,16 @@
                            ).match(self._uri[11:])
             if not m:
                 raise SyntaxError, "Invalid URI string in SQLDB"
-            user = m.group('user')
+            user = unquote_plus(m.group('user'))
             if not user:
                 raise SyntaxError, 'User required'
-            passwd = m.group('passwd')
+            passwd = unquote_plus(m.group('passwd'))
             if not passwd:
                 passwd = ''
-            host = m.group('host')
+            host = unquote_plus(m.group('host'))
             if not host:
                 raise SyntaxError, 'Host name required'
-            db = m.group('db')
+            db = unquote_plus(m.group('db'))
             if not db:
                 raise SyntaxError, 'Database name required'
             port = m.group('port') or '5432'
@@ -1044,7 +1045,7 @@
                     if not m:
                         raise SyntaxError, \
                             'Parsing uri string(%s) has no result' % (self._uri[skip:])
-                    dsn = m.group('dsn')
+                    dsn = unquote_plus(m.group('dsn'))
                     if not dsn:
                         raise SyntaxError, 'DSN required'
                 except SyntaxError, e:
@@ -1058,16 +1059,16 @@
                 if not m:
                     raise SyntaxError, \
                         "Invalid URI string in SQLDB: %s" % self._uri
-                user = m.group('user')
+                user = unquote_plus(m.group('user'))
                 if not user:
                     raise SyntaxError, 'User required'
-                passwd = m.group('passwd')
+                passwd = unquote_plus(m.group('passwd'))
                 if not passwd:
                     passwd = ''
-                host = m.group('host')
+                host = unquote_plus(m.group('host'))
                 if not host:
                     raise SyntaxError, 'Host name required'
-                db = m.group('db')
+                db = unquote_plus(m.group('db'))
                 if not db:
                     raise SyntaxError, 'Database name required'
                 port = m.group('port') or '1433'
@@ -1099,21 +1100,21 @@
             if not m:
                 raise SyntaxError, \
                     "Invalid URI string in SQLDB: %s" % self._uri
-            user = m.group('user')
+            user = unquote_plus(m.group('user'))
             if not user:
                 raise SyntaxError, 'User required'
-            passwd = m.group('passwd')
+            passwd = unquote_plus(m.group('passwd'))
             if not passwd:
                 passwd = ''
-            host = m.group('host')
+            host = unquote_plus(m.group('host'))
             if not host:
                 raise SyntaxError, 'Host name required'
-            db = m.group('db')
+            db = unquote_plus(m.group('db'))
             if not db:
                 raise SyntaxError, 'Database name required'
             port = m.group('port') or '3050'
 
-            charset = m.group('charset') or 'UTF8'
+            charset = unquote_plus(m.group('charset') or 'UTF8')
 
             self._pool_connection(lambda : \
                     kinterbasdb.connect(dsn='%s/%s:%s' % (host, port, db),
@@ -1128,18 +1129,16 @@
             if not m:
                 raise SyntaxError, \
                     "Invalid URI string in SQLDB: %s" % self._uri
-            user = m.group('user')
+            user = unquote_plus(m.group('user'))
             if not user:
                 raise SyntaxError, 'User required'
-            passwd = m.group('passwd')
+            passwd = unquote_plus(m.group('passwd'))
             if not passwd:
                 passwd = ''
-            pathdb = m.group('path')
+            pathdb = unquote_plus(m.group('path'))
             if not pathdb:
                 raise SyntaxError, 'Path required'
-            charset = m.group('charset')
-            if not charset:
-                charset = 'UTF8'
+            charset = unquote_plus(m.group('charset') or 'UTF8')
             self._pool_connection(lambda : \
                     kinterbasdb.connect(host='',
                                         database=pathdb,
@@ -1156,16 +1155,16 @@
             if not m:
                 raise SyntaxError, \
                     "Invalid URI string in SQLDB: %s" % self._uri
-            user = m.group('user')
+            user = unquote_plus(m.group('user'))
             if not user:
                 raise SyntaxError, 'User required'
-            passwd = m.group('passwd')
+            passwd = unquote_plus(m.group('passwd'))
             if not passwd:
                 passwd = ''
-            host = m.group('host')
+            host = unquote_plus(m.group('host'))
             if not host:
                 raise SyntaxError, 'Host name required'
-            db = m.group('db')
+            db = unquote_plus(m.group('db'))
             if not db:
                 raise SyntaxError, 'Database name required'
             port = m.group('port') or '3050'
@@ -1196,16 +1195,16 @@
                            ).match(self._uri[11:])
             if not m:
                 raise SyntaxError, "Invalid URI string in SQLDB"
-            user = m.group('user')
+            user = unquote_plus(m.group('user'))
             if not user:
                 raise SyntaxError, 'User required'
-            passwd = m.group('passwd')
+            passwd = unquote_plus(m.group('passwd'))
             if not passwd:
                 passwd = ''
-            host = m.group('host')
+            host = unquote_plus(m.group('host'))
             if not host:
                 raise SyntaxError, 'Host name required'
-            db = m.group('db')
+            db = unquote_plus(m.group('db'))
             if not db:
                 raise SyntaxError, 'Database name required'
             port = m.group('port') or '5432'

