commit: 7d8a18896742f65f2d5d4aeb4383ab7273900b05
parent 73b337245bcc2b3f3809bcc476021f64943bdbcf
Author: Phantasm <phantasm@centrum.cz>
Date: Mon, 27 Oct 2025 18:49:34 +0100
Disable Hackney URL encoding function
Hackney interferes with out URI encoding and implements older RFC 2396
instead of RFC 3986 which we and Elixir implement. As an example "'"
and "!" will get encoded by it and cause problems with our MediaProxy
making unexpected 302 redirects.
If an admin supplies a different function via *.secret.exs, we
don't override it.
https://github.com/benoitc/hackney/issues/399
Diffstat:
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/lib/pleroma/http/adapter_helper/hackney.ex b/lib/pleroma/http/adapter_helper/hackney.ex
@@ -16,7 +16,12 @@ defmodule Pleroma.HTTP.AdapterHelper.Hackney do
config_opts = Pleroma.Config.get([:http, :adapter], [])
+ url_encoding =
+ Keyword.new()
+ |> Keyword.put(:path_encode_fun, fn path -> path end)
+
@defaults
+ |> Keyword.merge(url_encoding)
|> Keyword.merge(config_opts)
|> Keyword.merge(connection_opts)
|> add_scheme_opts(uri)
diff --git a/lib/pleroma/reverse_proxy/client/hackney.ex b/lib/pleroma/reverse_proxy/client/hackney.ex
@@ -7,6 +7,11 @@ defmodule Pleroma.ReverseProxy.Client.Hackney do
@impl true
def request(method, url, headers, body, opts \\ []) do
+ opts =
+ Keyword.put_new(opts, :path_encode_fun, fn path ->
+ path
+ end)
+
:hackney.request(method, url, headers, body, opts)
end
diff --git a/test/pleroma/reverse_proxy_test.exs b/test/pleroma/reverse_proxy_test.exs
@@ -396,7 +396,7 @@ defmodule Pleroma.ReverseProxyTest do
end
end
- # Hackey is used for Reverse Proxy when Hackney or Finch is the Tesla Adapter
+ # Hackney is used for Reverse Proxy when Hackney or Finch is the Tesla Adapter
# Gun is able to proxy through Tesla, so it does not need testing as the
# test cases in the Pleroma.HTTPTest module are sufficient
describe "Hackney URL encoding:" do