tpope/vim-dadbod

Authentication error on credentials with the character '#'

gustavoalves23 opened this issue · 1 comments

I am facing a issue where, when the DB connection URL has the character '#' on it, the URL is splited on this character, causing the authentication to fail.

I tried this on SQL Server, but i believe happens on other adapters.

Expected Behavior

Be able to authenticate on DBs with # on its password.

Current Behavior

DB refuses to authenticate because the password sent is wrong

Possible Solution

After some debug, i found out this line:

let url = substitute(url, '#.*', '', '')

Because of that, its removing everything after some '#'

Looks like the # character is related to something called fragment:

return matchstr(a:url, '#\zs.*')

But i don't know exacly what is it purpose.

i made a fork that just remove some lines related to them and fixed the problem for me, but probably broke something related to those fragments.

Steps to Reproduce

  1. Add the vim-dadbod plugin on vim.
  2. Run a container with sql server: docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=12345678#abc@" -e "MSSQL_PID=Evaluation" -p 1433:1433 --hostname sqlpreview -d mcr.microsoft.com/mssql/server:2022-preview-ubuntu-22.04
  3. Try to connect with the connection url: sqlserver://localhost:1433;user=sa;password=12345678#abc@
  4. It will fail, try to redo steps 2 and 3 but without the # on the password and it will work

Use %23.

Special characters in URL fields must be URL escaped. For example, if the
user is "me@example.com", and the password is "my#password?", the URL might
look like this:
>
mysql://me%40example.com:my%23password%3F@localhost/database