From ec5b3109e40a1f02779fd790671054ccd4c16e96 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 25 Jun 2016 00:38:47 +0200 Subject: [PATCH 1/2] Support for the case when the guid and public key will vanish from webfinger --- include/Scrape.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/include/Scrape.php b/include/Scrape.php index a26576a69e..d39c708f57 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -90,9 +90,18 @@ function scrape_dfrn($url, $dont_probe = false) { if(attribute_contains($item->getAttribute('class'), 'vcard')) { $level2 = $item->getElementsByTagName('*'); foreach($level2 as $x) { - if(attribute_contains($x->getAttribute('class'),'fn')) { + if(attribute_contains($x->getAttribute('class'),'uid')) + $ret['guid'] = $x->textContent; + if(attribute_contains($x->getAttribute('class'),'nickname')) + $ret['nickname'] = $x->textContent; + if(attribute_contains($x->getAttribute('class'),'fn')) $ret['fn'] = $x->textContent; - } + if(attribute_contains($x->getAttribute('class'),'searchable')) + $ret['searchable'] = $x->textContent; + if(attribute_contains($x->getAttribute('class'),'key')) + $ret['key'] = $x->textContent; + if(attribute_contains($x->getAttribute('class'),'url')) + $ret['url'] = $x->textContent; if((attribute_contains($x->getAttribute('class'),'photo')) || (attribute_contains($x->getAttribute('class'),'avatar'))) { $size = intval($x->getAttribute('width')); @@ -102,9 +111,6 @@ function scrape_dfrn($url, $dont_probe = false) { $largest_photo = (($size == 175) ? 9999 : $size); } } - if(attribute_contains($x->getAttribute('class'),'key')) { - $ret['key'] = $x->textContent; - } } } } @@ -585,6 +591,11 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) { // Diaspora will remove it from the webfinger somewhere in the future. if (($hcard != "") AND ($pubkey == "")) { $ret = scrape_dfrn(($hcard) ? $hcard : $dfrn, true); + if (isset($ret["guid"])) + $diaspora_guid = $ret["guid"]; + if (isset($ret["url"])) + $diaspora_base = $ret["url"]; + if (isset($ret["key"])) { $hcard_key = $ret["key"]; if(strstr($hcard_key,'RSA ')) @@ -593,8 +604,9 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) { $pubkey = $hcard_key; } } - if($diaspora && $diaspora_base && $diaspora_guid) { + if(($network != "") && $diaspora_base && $diaspora_guid) { $diaspora_notify = $diaspora_base.'receive/users/'.$diaspora_guid; + $diaspora = true; if($mode == PROBE_DIASPORA || !$notify || ($notify == $diaspora_notify)) { $notify = $diaspora_notify; From e2023b6667e861bd5e71f408ca69f5eb5be1ae9f Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 25 Jun 2016 11:52:52 +0200 Subject: [PATCH 2/2] Store the guid value as well. --- include/Scrape.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/Scrape.php b/include/Scrape.php index d39c708f57..32a93872c3 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -794,7 +794,10 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) { if(($network === NETWORK_FEED) && ($poll) && (! x($vcard,'fn'))) $vcard['fn'] = $url; - if (($notify != "") AND ($poll != "")) { + if ($diaspora_base != "") + $baseurl = $diaspora_base; + + if (($baseurl == "") AND ($notify != "") AND ($poll != "")) { $baseurl = matching_url(normalise_link($notify), normalise_link($poll)); $baseurl2 = matching_url($baseurl, normalise_link($profile)); @@ -824,6 +827,7 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) { $result['name'] = $vcard['fn']; $result['nick'] = $vcard['nick']; + $result['guid'] = $diaspora_guid; $result['url'] = $profile; $result['addr'] = $addr; $result['batch'] = $batch;