aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg/tasks/source_parser.py
diff options
context:
space:
mode:
authorDennis Fink2026-11-17 14:44:00 +0100
committerDennis Fink2026-11-17 14:44:00 +0100
commit227092b57acc886469e16bcc4c0d3256e86d3d1e (patch)
treec1de8d5f8f3a37562e482f84e8017213c08a05d6 /webmentions_ssg/tasks/source_parser.py
parentf98b0e446b41325c494bd97900b7bbf730a7d67e (diff)
downloadwebmentions-ssg-227092b57acc886469e16bcc4c0d3256e86d3d1e.tar.gz
webmentions-ssg-227092b57acc886469e16bcc4c0d3256e86d3d1e.zip
feat(receiver): add source domain access rules
Add persistent source block and allow lists with authenticated management, single-row and bulk blocking actions, and optional fail-closed allowlist mode. Reject disallowed sources before enqueueing and recheck policy in verification workers, while sharing canonical hostname normalization across receiver, sender, and configuration paths.
Diffstat (limited to 'webmentions_ssg/tasks/source_parser.py')
-rw-r--r--webmentions_ssg/tasks/source_parser.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/webmentions_ssg/tasks/source_parser.py b/webmentions_ssg/tasks/source_parser.py
index e063525..bd0700a 100644
--- a/webmentions_ssg/tasks/source_parser.py
+++ b/webmentions_ssg/tasks/source_parser.py
@@ -18,7 +18,8 @@ import xxhash
from bs4 import BeautifulSoup, Tag
from bs4.element import NavigableString, PageElement
-from ..net import is_http_url, normalized_hostname
+from ..hostname import normalize_hostname
+from ..net import is_http_url
REACTION_PROPERTIES = ("in-reply-to", "like-of", "repost-of", "bookmark-of")
@@ -284,7 +285,10 @@ def iter_outgoing_targets(
for value in chain(hrefs, reactions):
target = normalize_target_url(value, base_url=base_url, source_url=source_url)
if target is not None:
- hostname = normalized_hostname(target) or ""
+ try:
+ hostname = normalize_hostname(target, from_url=True)
+ except ValueError:
+ continue
if not any(fnmatchcase(hostname, pattern) for pattern in ignored_hostnames):
yield target