summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHaelwenn <contact+git.pleroma.social@hacktivis.me>2024-01-15 08:24:54 +0000
committerHaelwenn <contact+git.pleroma.social@hacktivis.me>2024-01-15 08:24:54 +0000
commit9b39bc6aa8238ab2084f813d50210b75bd80e374 (patch)
tree81322503421b516c01e06d206acc6e01c2c487f5 /lib
parentc29430b018d3ba34677d5f816f67e3b8d44ec685 (diff)
parent6af49270a9b1ddbdf8836139597b66695d8e1606 (diff)
downloadpleroma-9b39bc6aa8238ab2084f813d50210b75bd80e374.tar.gz
pleroma-9b39bc6aa8238ab2084f813d50210b75bd80e374.zip
Merge branch 'mrf-regex-error' into 'develop'
MRF: Log sensible regex error for subdomain_match See merge request pleroma/pleroma!4026
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/activity_pub/mrf.ex13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/pleroma/web/activity_pub/mrf.ex b/lib/pleroma/web/activity_pub/mrf.ex
index 7f6dce925..1071f8e6e 100644
--- a/lib/pleroma/web/activity_pub/mrf.ex
+++ b/lib/pleroma/web/activity_pub/mrf.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2023 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.MRF do
@@ -139,7 +139,16 @@ defmodule Pleroma.Web.ActivityPub.MRF do
@spec subdomains_regex([String.t()]) :: [Regex.t()]
def subdomains_regex(domains) when is_list(domains) do
- for domain <- domains, do: ~r(^#{String.replace(domain, "*.", "(.*\\.)*")}$)i
+ for domain <- domains do
+ try do
+ target = String.replace(domain, "*.", "(.*\\.)*")
+ ~r<^#{target}$>i
+ rescue
+ e ->
+ Logger.error("MRF: Invalid subdomain Regex: #{domain}")
+ reraise e, __STACKTRACE__
+ end
+ end
end
@spec subdomain_match?([Regex.t()], String.t()) :: boolean()