Don't check Link header if not set
This commit is contained in:
parent
ef4c11d262
commit
2b4a6c7dd7
|
@ -141,13 +141,16 @@ class LinkbackPlugin extends Plugin
|
||||||
// Based on https://github.com/indieweb/mention-client-php
|
// Based on https://github.com/indieweb/mention-client-php
|
||||||
// which is licensed Apache 2.0
|
// which is licensed Apache 2.0
|
||||||
function getWebmention($result) {
|
function getWebmention($result) {
|
||||||
// XXX: the fetcher only gives back one of each header, so this may fail on multiple Link headers
|
if (isset($result->headers['Link'])) {
|
||||||
if(preg_match('~<((?:https?://)?[^>]+)>; rel="webmention"~', $result->headers['Link'], $match)) {
|
// XXX: the fetcher only gives back one of each header, so this may fail on multiple Link headers
|
||||||
return $match[1];
|
if(preg_match('~<((?:https?://)?[^>]+)>; rel="webmention"~', $result->headers['Link'], $match)) {
|
||||||
} elseif(preg_match('~<((?:https?://)?[^>]+)>; rel="http://webmention.org/?"~', $result->headers['Link'], $match)) {
|
return $match[1];
|
||||||
return $match[1];
|
} elseif(preg_match('~<((?:https?://)?[^>]+)>; rel="http://webmention.org/?"~', $result->headers['Link'], $match)) {
|
||||||
|
return $match[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Do proper DOM traversal
|
||||||
if(preg_match('/<(?:link|a)[ ]+href="([^"]+)"[ ]+rel="[^" ]* ?webmention ?[^" ]*"[ ]*\/?>/i', $result->body, $match)
|
if(preg_match('/<(?:link|a)[ ]+href="([^"]+)"[ ]+rel="[^" ]* ?webmention ?[^" ]*"[ ]*\/?>/i', $result->body, $match)
|
||||||
|| preg_match('/<(?:link|a)[ ]+rel="[^" ]* ?webmention ?[^" ]*"[ ]+href="([^"]+)"[ ]*\/?>/i', $result->body, $match)) {
|
|| preg_match('/<(?:link|a)[ ]+rel="[^" ]* ?webmention ?[^" ]*"[ ]+href="([^"]+)"[ ]*\/?>/i', $result->body, $match)) {
|
||||||
return $match[1];
|
return $match[1];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user