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

password with special characters is difficult to connect with #205

Open
gregwebs opened this issue Dec 5, 2023 · 2 comments
Open

password with special characters is difficult to connect with #205

gregwebs opened this issue Dec 5, 2023 · 2 comments

Comments

@gregwebs
Copy link
Contributor

gregwebs commented Dec 5, 2023

The Rust URL encoding will encode the user password to https://url.spec.whatwg.org/#userinfo-percent-encode-set

However, PG itself points to this as the encoding: https://datatracker.ietf.org/doc/html/rfc3986#section-2.1

What works for me is to use jq -sRr '@uri' or more specifically

#!/usr/bin/env bash
set -euo pipefail

PGPASSWORD="${PGPASSWORD:-''}"
PGHOST="${PGHOST:-'localhost'}"
PGPORT="${PGPORT:-5432}"
password="$(echo -n "$PGPASSWORD" | jq -sRr '@uri')"
if echo $PGHOST | grep '/' >/dev/null ; then
  host='localhost'
else
  host="$(echo -n "$PGHOST" | jq -sRr '@uri')"
fi
echo "postgres://$PGUSER:${password}@${host}:$PGPORT/$PGDATABASE?sslmode=disable"
@gregwebs
Copy link
Contributor Author

gregwebs commented Dec 5, 2023

What I am doing is not passing any PG args to datanymizer other than --dbname as the url and also giving the url to pg_dump with pg_datanymize --dbname "$DATABASE_URL" -- $DATABASE_URL

@gregwebs
Copy link
Contributor Author

gregwebs commented Dec 6, 2023

hmm, also saw that strategy not work in a different case and reverted back to CLI args and it worked there.

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

1 participant