Description
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.