Bug #97664 | Connector Node.js rejects URI includes password with certain special characters | ||
---|---|---|---|
Submitted: | 16 Nov 2019 4:30 | Modified: | 18 Jan 2020 10:37 |
Reporter: | Mitani Satoshi (OCA) | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | Connector for Node.js | Severity: | S3 (Non-critical) |
Version: | 8.0.18 | OS: | Any |
Assigned to: | Rui Quelhas | CPU Architecture: | Any |
[16 Nov 2019 4:30]
Mitani Satoshi
[17 Nov 2019 5:28]
MySQL Verification Team
Hello Mitani, Thank you for the report and feedback. Verified as described. regards, Umesh
[18 Jan 2020 10:37]
Rui Quelhas
Sorry for the late answer and thank you for taking the time to write to us, but this is not a bug. Connection strings or URIs are based on a convention that stems from RFC 3986. In such constructs, characters like the ones mentioned have a special meaning, which means they need to be encoded somehow. In this case 'Password#123' would have to be encoded as 'Password%23123', where '#' is encoded as '%23'. One way to do that in JavaScript, is by using the global encodeURIComponent() function. So, the following would work as expected: // using ES6 template strings mysqlx.getSession(`mysqlx://appuser:${encodeURIComponent('Password#123')}@host name:33060`) // using string concatenation (for older ES versions) mysqlx.getSession('mysqlx://appuser:' + encodeURIComponent('Password#123') + '@hostname:33060') Alternatively, one can also use the API based on plain JavaScript Objects to specify the connection properties. In this case, the following also works: mysqlx.getSession({ user: 'appuser', password: 'Password#123', host: 'hostname' }) Also, bear in mind that Connector/Node.js is a client based on the X Protocol, which means it does not use libmysqlclient, and consequently, does not use C API mentioned in the documentation. The following links provide more details about Connector/Node.js, the X DevAPI and the X Protocol. https://dev.mysql.com/doc/dev/connector-nodejs/8.0/ https://dev.mysql.com/doc/x-devapi-userguide/en/ https://dev.mysql.com/doc/internals/en/x-protocol.html