Merge branch 'develop' into foxing-patch-1
[akkoma] / lib / pleroma / web / activity_pub / mrf.ex
index dae6d7f6a1ae74512336d46f2efd5e98fc6779f3..6ecd62c99e17f2ccbd4a0c0fb33bdb2050a34fbd 100644 (file)
@@ -161,10 +161,17 @@ defmodule Pleroma.Web.ActivityPub.MRF do
   # - https://extra.baddomain.net/
   # Does NOT match the following:
   # - https://maybebaddomain.net/
+
+  # *.baddomain.net
   def subdomain_regex("*." <> domain), do: subdomain_regex(domain)
 
+  # baddomain.net
   def subdomain_regex(domain) do
-    ~r/^(.+\.)?#{Regex.escape(domain)}$/i
+    if String.ends_with?(domain, ".*") do
+      ~r/^(.+\.)?#{Regex.escape(String.replace_suffix(domain, ".*", ""))}\.(.+)$/i
+    else
+      ~r/^(.+\.)?#{Regex.escape(domain)}$/i
+    end
   end
 
   @spec subdomains_regex([String.t()]) :: [Regex.t()]