commit: 6b6a2adb07c3b9a52cd0a5adf435a916088bb4d7
parent 6551ca2db7a0907252bbc649c7d082b3edf92a93
Author: Mark Felder <feld@feld.me>
Date: Tue, 28 May 2024 10:49:43 -0400
Dialyzer: The function call will not succeed.
:idna.encode/1 expects a charlist even though it will accept a binary string. That functionality is undocumented / not part of its typespec, so we should turn it into a charlist first. Also switch to using match?/2
lib/pleroma/user.ex:2056:call
The function call will not succeed.
:idna.encode(_host :: binary())
will never return since the success typing is:
(string()) :: string()
and the contract is
(string()) :: string()
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
@@ -2053,7 +2053,8 @@ defmodule Pleroma.User do
%{scheme: scheme, userinfo: nil, host: host}
when not_empty_string(host) and scheme in ["http", "https"] <-
URI.parse(value),
- {:not_idn, true} <- {:not_idn, to_string(:idna.encode(host)) == host},
+ {:not_idn, true} <-
+ {:not_idn, match?(^host, to_string(:idna.encode(to_charlist(host))))},
"me" <- Pleroma.Web.RelMe.maybe_put_rel_me(value, profile_urls) do
CommonUtils.to_masto_date(NaiveDateTime.utc_now())
else