Skip to content

Fix how we set FDW password to handle especial characters

What does this MR do?

When the FDW passwords contain curly brackets, double quotes or backslashes, the "umoptions" returns an escaped string with double quotes wrapping the key and value together:

gitlabhq_geo_production=# ALTER USER MAPPING FOR gitlab_geo SERVER gitlab_secondary OPTIONS (SET user 'gitlab', SET password 'foo}bar"zoo\cat');
ALTER USER MAPPING
gitlabhq_geo_production=# SELECT umoptions FROM pg_user_mappings WHERE srvname='gitlab_secondary' AND usename='gitlab_geo';
                 umoptions
--------------------------------------------
 {user=gitlab,"password=foo}bar\"zoo\\cat"}
(1 row)

The result {user=gitlab,"password=foo}bar\"zoo\\cat"} is not correctly parsed into a Ruby hash. This MR unescape the escaped values and removes the double quotes that wrap the key and value before resulting in a valid Ruby hash {:user=>"gitlab", :password=>'foo}bar"zoo\cat'}.

Related issues

Closes #3958 (closed)

Edited by GitLab Release Tools Bot

Merge request reports