aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'webmentions_ssg/tasks')
-rw-r--r--webmentions_ssg/tasks/source_parser.py8
-rw-r--r--webmentions_ssg/tasks/verification.py6
2 files changed, 11 insertions, 3 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
diff --git a/webmentions_ssg/tasks/verification.py b/webmentions_ssg/tasks/verification.py
index b0f4d0f..d55608c 100644
--- a/webmentions_ssg/tasks/verification.py
+++ b/webmentions_ssg/tasks/verification.py
@@ -25,10 +25,10 @@ from ..net import (
media_type_of,
read_limited_body,
)
+from ..source_policy import source_rejection_reason
from ..version import APP_NAME, VERSION
from .target_matching import html_mentions_target, text_mentions_target
-
RECOVERY_EXHAUSTED_REASON = "Verification recovery limit reached"
@@ -200,6 +200,10 @@ def determine_verification_outcome(
retried.
:raises httpx.RequestError: If a transient HTTP request error should be retried.
"""
+ # Recheck at worker time: a source may have been blocked since submission.
+ if reason := source_rejection_reason(claim.source):
+ return ReceivedWebmentionStatus.FAILED, reason
+
try:
mentions_target = source_mentions_target(claim.source, claim.target)
except SourceGoneError as exc: