Skip to content

fix(config): handle special characters in connection string credentials - #297

Open
normal88 wants to merge 1 commit into
overextended:mainfrom
normal88:fix/connection-string-credentials
Open

normal88 wants to merge 1 commit into
overextended:mainfrom
normal88:fix/connection-string-credentials

Conversation

@normal88

Copy link
Copy Markdown

I ran into this issue on my own server, where the database password contained special characters and oxmysql kept failing to connect with a generic Access denied error. After tracking it down to the connection string parser, I decided to put together a fix for it.

Problem

Passwords containing certain characters are silently mangled when parsing mysql_connection_string:

Connection string Parsed password
mysql://root:pa:ss@localhost/db pa
mysql://root:p%40ss@localhost/db p%40ss (never decoded)
host=localhost;user=root;password=ab=cd ab

Because URI credentials were never percent-decoded, there was no way to use a password containing #, / or ? in the URI format at all.

Fix

  • URI: split credentials on the first : only and percent-decode user/password (standard URI behaviour). Invalid sequences (e.g. a literal %) fall back to the raw value, so existing configs keep working.
  • URI query params and the key=value; format: split on the first = only.

Tests

Added cases to tests/unit/config.test.ts; four of them fail on main and pass with this change. bun test tests/unit: 143 pass.

- URI: split user/password on the first ':' only and percent-decode them
- URI query params and key=value format: split on the first '=' only

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant