tpope / vim-dadbod

dadbod.vim: Modern database interface for Vim
https://www.vim.org/scripts/script.php?script_id=5665
3.64k stars 129 forks source link

Authentication error on credentials with the character '#' #170

Closed gustavoalves23 closed 4 months ago

gustavoalves23 commented 4 months ago

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:

https://github.com/tpope/vim-dadbod/blob/37523ffe0849b51db07fa7f48430c2aca5420a0e/autoload/db/url.vim#L20

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

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

https://github.com/tpope/vim-dadbod/blob/37523ffe0849b51db07fa7f48430c2aca5420a0e/autoload/db/url.vim#L113 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
tpope commented 4 months ago

Use %23.

https://github.com/tpope/vim-dadbod/blob/acb78e078dc4fe1e997ebf006be17aa3766d2ef4/doc/dadbod.txt#L47-L51