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

connection string parsing is invalid #1704

Closed
rafipiccolo opened this issue Nov 20, 2022 · 1 comment
Closed

connection string parsing is invalid #1704

rafipiccolo opened this issue Nov 20, 2022 · 1 comment

Comments

@rafipiccolo
Copy link

static parseUrl(url) {

To parse the connection string, we use "new Url(xxx)" but it looks like it urlencodes the parameters : Hence invalidating them when there are special chars.

imagine the password is xx^xx

the connection string can be :
mysql://root:xx^xx@xx.com/xx?charset=utf8mb4
or
mysql://root:xx%5Exx@xx.com/xx?charset=utf8mb4
both usually work in other libs.

it's worth noting that "new Url()" returns in both cases "password: xx%5Exx"
then ofc the connection cant be established because the password is wrong.

Since we use new Url, we should pass the "password" through decodeURIComponent to get it correctly.

IMHO valid parser would be :

const options = {
      host: parsedUrl.hostname,
      port: parsedUrl.port,
      database: parsedUrl.pathname.slice(1),
      user: parsedUrl.username,
      password: decodeURIComponent(parsedUrl.password)
};
@sidorares
Copy link
Owner

see #1621
feel free to reopen if you think this is a separate issue

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

2 participants