diff options
author | Mark Felder <feld@feld.me> | 2024-05-28 10:49:43 -0400 |
---|---|---|
committer | Mark Felder <feld@feld.me> | 2024-05-28 10:49:43 -0400 |
commit | 6b6a2adb07c3b9a52cd0a5adf435a916088bb4d7 (patch) | |
tree | 2c9b2eba0727ecf24b3e79ab371b18e1071c831f | |
parent | 6551ca2db7a0907252bbc649c7d082b3edf92a93 (diff) | |
download | pleroma-6b6a2adb07c3b9a52cd0a5adf435a916088bb4d7.tar.gz pleroma-6b6a2adb07c3b9a52cd0a5adf435a916088bb4d7.zip |
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()
-rw-r--r-- | lib/pleroma/user.ex | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index d94b68ce0..884c1f302 100644 --- 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 |