Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special characters in password causing login failure #782

Open
sagar-shah-uipath opened this issue May 10, 2023 · 2 comments
Open

Special characters in password causing login failure #782

sagar-shah-uipath opened this issue May 10, 2023 · 2 comments

Comments

@sagar-shah-uipath
Copy link

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
Copy link

elsgaard commented May 25, 2023

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

@pasckosky
Copy link

I run on the same problem.
A password like AJ;34#92=3

I tried to enclose in single quotes, no way
I tried to url escape, no way

At the end I found the root of the problem in the first lines of the splitConnectionString function in package msdsn, file conn_str.go

A the very beginning of the function there is a strings.Split over ";" but without looking for condition of string enclosed in quotes or not.

My workaround was to remove the password from the connection string and set it manually after the Parse

That is at the end:

connStr:="server=hostname;port=1433;user id=username"
cfg, _, _ := msdsn.Parse(connString)
cfg.Password="AJ;34#92=3"

In this way, not including the password in the connection string I did not run into any problem and by specifying it directly there is no need of any kind of escape or other.

In this way the connection works with both simple password without special characters or any password that is accepted by SQLServer

My 2¢, hoping to help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants