denisenkom / go-mssqldb

Microsoft SQL server driver written in go language
BSD 3-Clause "New" or "Revised" License
1.82k stars 499 forks source link

Special characters in password causing login failure #782

Open sagar-shah-uipath opened 1 year ago

sagar-shah-uipath commented 1 year ago

Describe the bug When there are special characters in password in connection string, It fails with login failed. We do use many special characters in password, not sure which exact character is causing failures

To Reproduce Try using password like @-(^-d:ec1/$P;~L=,#''e:L;8Nd*{)o2Xcj=~R);U-[5c/7z in connection string

Expected behavior Login should pass because password is correct

Further technical details

SQL Server version: SQL Server 2017 Operating system: RHEL

elsgaard commented 1 year ago

Yeah i have noticed the same problem. It seems to be caused by the function: splitConnectionStringURL which uses the url.Parse() from net/url to parse the dsn. url.Parse() expects the browser to correctly escape characters.

Workaround: The workaround (that is working for me), is to url-encode the password like: 1234#!456 is encoded to: 123%23%21456 Now the DB connection is created with the correct password: 1234#!456