X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FWebFinger%2FWebFingerPlugin.php;h=942eab27cfe4394d77b69d66559b21e67ce4ce43;hb=d063afe10ecf85b31cc49a454ec8e664927c9e26;hp=1edc3d8971351790ac70f9fc22418800814a6237;hpb=44ebf768ba60377b29b6c765020410a0c115e91a;p=quix0rs-gnu-social.git diff --git a/plugins/WebFinger/WebFingerPlugin.php b/plugins/WebFinger/WebFingerPlugin.php index 1edc3d8971..942eab27cf 100644 --- a/plugins/WebFinger/WebFingerPlugin.php +++ b/plugins/WebFinger/WebFingerPlugin.php @@ -100,15 +100,36 @@ class WebFingerPlugin extends Plugin } } } else { - $user = User::getKV('uri', $resource); - if ($user instanceof User) { + try { + $user = User::getByUri($resource); $profile = $user->getProfile(); - } else { - // try and get it by profile url - $profile = Profile::getKV('profileurl', $resource); + } catch (NoResultException $e) { + if (common_config('fix', 'fancyurls')) { + try { + try { // if it's a /index.php/ url + // common_fake_local_fancy_url can throw an exception + $alt_url = common_fake_local_fancy_url($resource); + } catch (Exception $e) { // let's try to create a fake local /index.php/ url + // this too if it can't do anything about the URL + $alt_url = common_fake_local_nonfancy_url($resource); + } + + // and this will throw a NoResultException if not found + $user = User::getByUri($alt_url); + $profile = $user->getProfile(); + } catch (Exception $e) { + // apparently we didn't get any matches with that, so continue... + } + } } } + // if we still haven't found a match... + if (!$profile instanceof Profile) { + // if our rewrite hack didn't work, try to get something by profile URL + $profile = Profile::getKV('profileurl', $resource); + } + if ($profile instanceof Profile) { $target = new WebFingerResource_Profile($profile); return false; // We got our target, stop handler execution @@ -144,8 +165,8 @@ class WebFingerPlugin extends Plugin public function onStartShowHTML(Action $action) { if ($action instanceof ShowstreamAction) { - $acct = 'acct:'. $action->getTarget()->getNickname() .'@'. common_config('site', 'server'); - $url = common_local_url('webfinger') . '?resource='.$acct; + $resource = $action->getTarget()->getUri(); + $url = common_local_url('webfinger') . '?resource='.urlencode($resource); foreach (array(Discovery::JRD_MIMETYPE, Discovery::XRD_MIMETYPE) as $type) { header('Link: <'.$url.'>; rel="'. Discovery::LRDD_REL.'"; type="'.$type.'"', false);