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

Missing explanation of what characters need to be escaped for doctrine DB password #20760

Open
justin-oh opened this issue Mar 12, 2025 · 3 comments

Comments

@justin-oh
Copy link

I have a password with the following special characters $;{#]@. I have successfully encoded this password in the past to work with the DSN format. I first had to urlencode() the raw password, then because of the usage of resolve: I had to additionally escape the % characters. For example, the $ is encoded to %24 which is finally escaped as %%24.

Here is the example DSN format that is working where the fake raw password would be a$b;cdefg{hijkl#]mno@:

DATABASE_URL="mysql://USER:a%%24b%%3Bcdefg%%7Bhijkl%%23%%5Dmno%%40@localhost:3306/DATABASE?serverVersion=VERSION&charset=CHARSET"

I have since started moving towards the separate parameters:

dbname: '%env(resolve:DATABASE_NAME)%'
host: '%env(resolve:DATABASE_HOST)%'
port: '%env(resolve:DATABASE_PORT)%'
user: '%env(resolve:DATABASE_USER)%'
password: '%env(resolve:DATABASE_PASSWORD)%'
server_version: '%env(resolve:DATABASE_SERVER_VERSION)%'

but I was struggling with how to set the value of DATABASE_PASSWORD. I tried the following:

# raw password
DATABASE_PASSWORD="a$b;cdefg{hijkl#]mno@"
# url encoded
DATABASE_PASSWORD="a%24b%3Bcdefg%7Bhijkl%23%5Dmno%40"
# url encoded + parameter escaped
DATABASE_PASSWORD="a%%24b%%3Bcdefg%%7Bhijkl%%23%%5Dmno%%40"

I tried getting rid of the resolve: for the password parameter. I tested that the password worked on the command line. I eventually gave up and changed the password to not contain any special characters.

@94noni
Copy link
Contributor

94noni commented Mar 15, 2025

And with the « urlencode » env processor does this works?
From https://symfony.com/doc/current/configuration/env_var_processors.html

@justin-oh
Copy link
Author

And with the « urlencode » env processor does this works? From https://symfony.com/doc/current/configuration/env_var_processors.html

I'm on version 6.4 so that is not an option.

@94noni
Copy link
Contributor

94noni commented Mar 17, 2025

perhaps add it in your codebase (via interface) for the time you upgrade to latest ?
otherwise, yes swaping your password I think lol is best option

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