-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Unable to Run with Apostrophe in Password #776
Comments
I think we've discussed using printf %q to sanitize the password before, but iirc there was some case where it would break. |
Indeed, we did discuss that -- MariaDB took a slightly different approach recently: # SQL escape the string $1 to be placed in a string literal.
# escape, \ followed by '
docker_sql_escape_string_literal() {
local escaped=${1//\\/\\\\}
echo "${escaped//\'/\\\'}"
} |
In a couple years, the MariaDB code has only really changed to also account for newlines: 👀 # SQL escape the string $1 to be placed in a string literal.
# escape, \ followed by '
docker_sql_escape_string_literal() {
local newline=$'\n'
local escaped=${1//\\/\\\\}
escaped="${escaped//$newline/\\n}"
echo "${escaped//\'/\\\'}"
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If the
MYSQL_ROOT_PASSWORD
value contains an apostrophe or single quote ('), the image fails to run whatsoever.I'm not sure if this would be considered a vulnerability, as only the administrator would have access to the Docker Compose file. However, it is a bother when one has a seemingly simple configuration, and turns out it was just the choice of password messing things up.
Logs:
The following works, and instead of using this as the password, it actually executes my
SELECT
.Logs:
The text was updated successfully, but these errors were encountered: