Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webmention endpoint resolution failing when there are multiple links in header #41

Closed
campegg opened this issue Oct 3, 2022 · 3 comments

Comments

@campegg
Copy link

campegg commented Oct 3, 2022

When sending a webmention to a site that returns multiple links in the header, the resolved endpoint URL gets mashed together with other link values. For example, if the site returns a header like this:

HTTP/1.1 200 OK
Date: Mon, 03 Oct 2022 19:33:58 GMT
Content-Type: text/html
Content-Length: 16887
Last-Modified: Sun, 02 Oct 2022 20:46:59 GMT
link: <https://websub.io>; rel="websub"
link: <https://websub.io>; rel="websub"
link: <https://webmention.io>; rel="webmention"
Referrer-Policy: no-referrer
X-Content-Type-Options: nosniff
Accept-Ranges: bytes

The URL endpoint resolves as:

https://websub.io>; rel="websub",<https://websub.io>; rel="websub",<https://webmention.io

I think it has something to do with the regex in the _get_endpoint_in_http_headers function; if the string "webmention" is found in the headers, it looks like it might be matching everything from the https at start of the first URL until it finds the webmention URL?

@beatonma
Copy link
Owner

beatonma commented Oct 4, 2022

Thanks for the report - will be fixed in next release.

beatonma added a commit that referenced this issue Oct 5, 2022
- Resolves [#38](#38):
  Revalidate target URLs when handling pending mentions
  - Should be unnecessary generally (they are also validated at
    discovery time when parsed from HTML) but important if validation
    checks are updated.

- Resolves [#41](#41): Find
  correct endpoint when multiple `link`s in HTTP header.

- Added `settings.WEBMENTIONS_INCOMING_TARGET_MODEL_REQUIRED` \[`bool` |
  default=`False`]. If `True`, incoming mentions are only accepted if
  their target resolves to a `MentionableMixin` instance.

- Added `settings.WEBMENTIONS_ALLOW_SELF_MENTIONS` \[`bool` |
  default=`True`].
  - If `False`, outgoing links that target your own domain (as specified
    by `settings.DOMAIN_NAME`) will be ignored - you will only submit
    mentions to other domains.
  - If `True`, outgoing links that use a relative path
    (e.g. `href="/article/1/"`) are now supported.
beatonma added a commit that referenced this issue Oct 5, 2022
- Resolves [#38](#38):
  Revalidate target URLs when handling pending mentions
  - Should be unnecessary generally (they are also validated at
    discovery time when parsed from HTML) but important if validation
    checks are updated.

- Resolves [#41](#41): Find
  correct endpoint when multiple `link`s in HTTP header.

- Added `settings.WEBMENTIONS_INCOMING_TARGET_MODEL_REQUIRED` \[`bool` |
  default=`False`]. If `True`, incoming mentions are only accepted if
  their target resolves to a `MentionableMixin` instance.

- Added `settings.WEBMENTIONS_ALLOW_SELF_MENTIONS` \[`bool` |
  default=`True`].
  - If `False`, outgoing links that target your own domain (as specified
    by `settings.DOMAIN_NAME`) will be ignored - you will only submit
    mentions to other domains.
  - If `True`, outgoing links that use a relative path
    (e.g. `href="/article/1/"`) are now supported.
beatonma added a commit that referenced this issue Oct 5, 2022
- Resolves [#38](#38):
  Revalidate target URLs when handling pending mentions
  - Should be unnecessary generally (they are also validated at
    discovery time when parsed from HTML) but important if validation
    checks are updated.

- Resolves [#41](#41): Find
  correct endpoint when multiple `link`s in HTTP header.

- Added `settings.WEBMENTIONS_INCOMING_TARGET_MODEL_REQUIRED` \[`bool` |
  default=`False`]. If `True`, incoming mentions are only accepted if
  their target resolves to a `MentionableMixin` instance.

- Added `settings.WEBMENTIONS_ALLOW_SELF_MENTIONS` \[`bool` |
  default=`True`].
  - If `False`, outgoing links that target your own domain (as specified
    by `settings.DOMAIN_NAME`) will be ignored - you will only submit
    mentions to other domains.
  - If `True`, outgoing links that use a relative path
    (e.g. `href="/article/1/"`) are now supported.
@beatonma
Copy link
Owner

beatonma commented Oct 6, 2022

Fixed in 3.1.0 - I also noticed that the WebmentionHeadMiddleware was overwriting any pre-existing links in the headers so that's been fixed now too.

@campegg
Copy link
Author

campegg commented Oct 6, 2022

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants