X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FLinkback%2FLinkbackPlugin.php;h=941e7c4c4b9241705c02dbddefb3e35586973bfe;hb=2b4a6c7dd723c404a48b629766279c24b45f54b4;hp=0ab76f1d53512ee9688bdce5407a3d65225155fb;hpb=ef4c11d262fa6d21dabc39b3fc9f12c54ad87488;p=quix0rs-gnu-social.git diff --git a/plugins/Linkback/LinkbackPlugin.php b/plugins/Linkback/LinkbackPlugin.php index 0ab76f1d53..941e7c4c4b 100644 --- a/plugins/Linkback/LinkbackPlugin.php +++ b/plugins/Linkback/LinkbackPlugin.php @@ -141,13 +141,16 @@ class LinkbackPlugin extends Plugin // Based on https://github.com/indieweb/mention-client-php // which is licensed Apache 2.0 function getWebmention($result) { - // XXX: the fetcher only gives back one of each header, so this may fail on multiple Link headers - if(preg_match('~<((?:https?://)?[^>]+)>; rel="webmention"~', $result->headers['Link'], $match)) { - return $match[1]; - } elseif(preg_match('~<((?:https?://)?[^>]+)>; rel="http://webmention.org/?"~', $result->headers['Link'], $match)) { - return $match[1]; + if (isset($result->headers['Link'])) { + // XXX: the fetcher only gives back one of each header, so this may fail on multiple Link headers + if(preg_match('~<((?:https?://)?[^>]+)>; rel="webmention"~', $result->headers['Link'], $match)) { + 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) || preg_match('/<(?:link|a)[ ]+rel="[^" ]* ?webmention ?[^" ]*"[ ]+href="([^"]+)"[ ]*\/?>/i', $result->body, $match)) { return $match[1];