Christian Boos committed dd1889c

0.10.4dev: ported r5136 and r5096 at the same occasion (''fix #5024 and #4866'')

Comments (0)

Files changed (2)

 from trac.config import Option, IntOption
 from trac.core import *
 from trac.db.pool import ConnectionPool
+from trac.util.text import unicode_unquote, unicode_passwd
 def get_column_names(cursor):
                     candidates[scheme] = (connector, priority)
             connector = candidates.get(scheme, [None])[0]
         if not connector:
-            raise TracError, 'Unsupported database type "%s"' % scheme
+            raise TracError('Unsupported database type "%s"' % scheme)
         if scheme == 'sqlite':
             # Special case for SQLite to support a path relative to the
             host = None
             path = rest
-            raise TracError, 'Database connection string %s must start with ' \
-                             'scheme:/' % db_str
+            raise TracError('Database connection string must start with '
+                            'scheme:/')
         if rest.startswith('/') and not rest.startswith('//'):
             host = None
             user, password = user.split(':', 1)
             password = None
+        if user:
+            user = unicode_unquote(user)
+        if password:
+            password = unicode_passwd(unicode_unquote(password))
         user = password = None
     if host and host.find(':') != -1:
         qs = qs.split('&')
         for param in qs:
             name, value = param.split('=', 1)
-            value = urllib.unquote(value)
+            value = unicode_unquote(value)
             params[name] = value
     args = zip(('user', 'password', 'host', 'port', 'path', 'params'),


         return u.encode('utf-8')
+class unicode_passwd(unicode):
+    """Conceal the actual content of the string when `repr` is called."""
+    def __repr__(self):
+        return '*******'
 # -- Plain text formatting
 def shorten_line(text, maxlen=75):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.