Actually, I'm going to go back on what I said. using
decode_credentials=True does not change the behavior of some of the
adapters. The MSSQL adapter, for example, did not extract the user or
password from the url by calling credential_decoder:
user = m.group('user')
...
password = m.group('password')
should be:
user = credential_decoder(m.group('user'))
...
password = credential_decoder(m.group('password'))
The only adapters that do this correctly are:
MySQL
FireBird
FireBirdEmbedded
Informix
On Jan 21, 3:30 pm, Massimo Di Pierro <[email protected]>
wrote:
> The proper way to handle this is the following:
>
> from urllib import quote, unquote
>
> db = DAL('mssql://%s:%s@hostname:password/db' %
> (quote(username),quote(password)),credential_decoder=unquote)
>
> On Jan 21, 3:45 pm,LorenMcGinnis <[email protected]> wrote:
>
>
>
>
>
>
>
> > I recently tried connecting to an mssql legacy database, and was
> > getting errors upon trying to connect.
>
> > I found out the problem, which was very specific to my case: I had an
> > "@" in my password. The regex currently used to parse the driver
> > string is:
>
> > '^(?P<user>[^:@]+)(\:(?P<password>[^@]*))?@(?P<host>[^\:/]+)(\:(?
> > P<port>[0-9]+))?/(?P<db>[^\?]+)(\?(?P<urlargs>.*))?$'
>
> > This truncated the password before the "@" and appended the rest onto
> > the hostname. I fixed it with this change, allowing the password to
> > be any characters:
>
> > '^(?P<user>[^:@]+)(\:(?P<password>.*))?@(?P<host>[^\:/]+)(\:(?
> > P<port>[0-9]+))?/(?P<db>[^\?]+)(\?(?P<urlargs>.*))?$'
>
> > It successfully parsed the string and connected after the change. Of
> > course, there would still be an issue if "@" showed up later in the
> > connection string (would this ever happen?), since I'm depending upon
> > a greedy qualifier to grab the whole password.