不要怂,就是干,撸起袖子干!

Commit b4c8b4ca by Jochem Maas Committed by Sushant

make it possible to use ":" in passwords in a DSN (#6348)

this change makes it possible to initialize Sequelize with a DSN that contains a password which contains one or more ":" characters, e.q.

```js
const Sequelize = require('sequelize')
const instance = Sequelize('mysql://root:234*%25%26%23%24%5E%40%23%7B%7D::\'.%26%40%40@localhost:3600', {});
```

in this example the MySQL password would be: `234*%&#$^@#{}::'.&@@`

without this change Sequelize attempts to connect to MySQL with a password of `234*%&#$^@#{}` ... this is a truncated password that results in a failed connection.
1 parent eab3a46d
Showing with 6 additions and 2 deletions
...@@ -139,8 +139,12 @@ class Sequelize { ...@@ -139,8 +139,12 @@ class Sequelize {
} }
if (urlParts.auth) { if (urlParts.auth) {
config.username = urlParts.auth.split(':')[0]; const authParts = urlParts.auth.split(':');
config.password = urlParts.auth.split(':')[1];
config.username = authParts[0];
if (authParts.length > 1)
config.password = authParts.slice(1).join(':');
} }
} else { } else {
// new Sequelize(database, username, password, { ... options }) // new Sequelize(database, username, password, { ... options })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!