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

Fix: Parse url with encoded hash in password #275

Merged

Conversation

ftes
Copy link
Contributor

@ftes ftes commented Jun 27, 2023

Actual

# config.exs
config :my_app, MyApp.EventStore,
  url: "postgres://username:password%23with_hash@localhost/database"

Error: path should be a database name

Expected

No error, connects to database with decoded password password#with_hash.

Details

URI was decoded twice: parser.ex:42 and parser.ex:71

@@ -39,7 +39,7 @@ defmodule EventStore.Config.Parser do
defp parse_url(""), do: []

defp parse_url(url) do
info = url |> URI.decode() |> URI.parse()
info = URI.parse(url)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs for URI.decode/1 give this example:

iex> URI.decode("https%3A%2F%2Felixir-lang.org")
"https://elixir-lang.org"

Was that the purpose of this invocation?
The eventstore docs and tests don't mention that an encoded DATABASE_URL is supported, though.

As a reference, Ecto.Repo also does not seem to support that.

@slashdotdash slashdotdash merged commit a862d02 into commanded:master Oct 18, 2023
slashdotdash added a commit that referenced this pull request Oct 18, 2023
slashdotdash added a commit that referenced this pull request Jan 9, 2024
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

Successfully merging this pull request may close these issues.

2 participants