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.

Reply via email to