diff options
Diffstat (limited to 'webmentions_ssg/tasks')
| -rw-r--r-- | webmentions_ssg/tasks/sender.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/webmentions_ssg/tasks/sender.py b/webmentions_ssg/tasks/sender.py index cceefcd..8834934 100644 --- a/webmentions_ssg/tasks/sender.py +++ b/webmentions_ssg/tasks/sender.py @@ -257,7 +257,14 @@ def post_webmention( if response.status_code == 201 and ( location := response.headers.get("Location") ): - status_url = urljoin(str(response.url), location) + try: + candidate = urljoin(str(response.url), location) + except ValueError: + # A malformed Location must not fail an otherwise successful send. + pass + else: + if is_http_url(candidate): + status_url = candidate return (response.status_code, status_url) @@ -399,7 +406,9 @@ def send_webmention(webmention_uuid: uuid.UUID) -> None: webmention.endpoint = endpoint webmention.response_status = response_status - webmention.status_url = status_url + webmention.status_url = ( + status_url if status_url is not None and is_http_url(status_url) else None + ) webmention.last_sent_at = datetime.now(UTC) |
