tpope / vim-dadbod

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

DB connection via URI does not work when password contains &]~^ symbols #171

Closed RicardoRamirezR closed 6 months ago

RicardoRamirezR commented 6 months ago

Good day,

Given this password #X!12j999%&]vK~^SQX

The DB URI that looks like: mysql://user:%23X!12j999%&]vK~^SQX@127.0.0.1/example

I encoded # as %23

The connector seems to take the password up to the first & and DB gives:

[DBUI]
Error connecting to db example: DB exec error: 
mysql: [ERROR] unknown variable '&]vK~^SQX@127.0.0.1:5000/example=1'

I've tried to encode:

With no luck

tpope commented 6 months ago

Try with :DB mysql://user:%23X!12j999%&]vK~^SQX@127.0.0.1/example SELECT 1. Does that work? If so, it's a Dadbod UI issue, not a Dadbod issue.

RicardoRamirezR commented 6 months ago

Try with :DB mysql://user:%23X!12j999%&]vK~^SQX@127.0.0.1/example SELECT 1. Does that work? If so, it's a Dadbod UI issue, not a Dadbod issue.

Thank you @tpope, same error message:

db

and the with: :echo db#url#parse('mysql://user:%23X121999861VK-SQX0127.0.0.1/example')

I got: {'host': '127.0.0.1', 'user': 'user', 'params': {}, 'password': '#X!12j999%&]vK~^SQX', 'scheme': 'mysql', 'path': '/example'}

tpope commented 6 months ago
:echo db#adapter#mysql#interactive('mysql://user:%23X!12j999%&]vK~^SQX@127.0.0.1/example')
['mysql', '-h', '127.0.0.1', '-u', 'user', '-p#X!12j999%&]vK~^SQX', 'example']

I don't have a MySQL install handy. What happens when you run the corresponding shell command?

mysql -h 127.0.0.1 -u user "-p#X!12j999%&]vK~^SQX" example
RicardoRamirezR commented 6 months ago

I got:

Screenshot 2024-05-18 at 3 09 16 PM
RicardoRamirezR commented 6 months ago

BUT when I encode %& with %25%26 as: mysql://user:%23X!12j999%25%26]vK~^SQX@127.0.0.1/example it works. I thought I had done all the substitutions before, I just rechecked and made the correction. Thank you for your time.

tpope commented 6 months ago

I don't fully understand what went wrong here, but you should indeed encode those, so I guess we have our solution.