beatonma / django-wm

Automatic Webmention functionality for Django models
https://beatonma.org/webmentions_tester/
GNU General Public License v3.0
12 stars 2 forks source link

Webmention endpoint resolution failing when there are multiple `link`s in header #41

Closed campegg closed 1 year ago

campegg commented 1 year ago

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 commented 1 year ago

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

beatonma commented 1 year ago

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 commented 1 year ago

Thank you!