From d14ae8b377a56cb1d0750127c03db2ae6bff3627 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Wed, 16 Oct 2024 09:24:20 +0200 Subject: [PATCH] properly escape quotes in passwords by calling to_ruby database passwords can contain special characters, especially " and ' so we can't just print the value of the field enclosed by double quotes as that would break whenever the user uses a literal " in their password using to_ruby here and not to_yaml, as the former gives us correct escaping without the whole `---` and `\n` enclosing that to_yaml forces. using to_yaml would require to pass *the whole* config hash to it --- templates/database.yml.epp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/database.yml.epp b/templates/database.yml.epp index 7e45e2627..444cdfd10 100644 --- a/templates/database.yml.epp +++ b/templates/database.yml.epp @@ -30,6 +30,6 @@ username: <%= $username %> <% } -%> <% if $password { -%> - password: "<%= $password %>" + password: <%= stdlib::to_ruby($password) %> <% } -%> pool: <%= $db_pool %>