X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fsalmon.php;h=300ad87466806cf2d982673f66b4d30d6b4b2f03;hb=2abcf76ec17a9a7754c399cdde9a4449308a4b02;hp=8c7d921c86041328549b7e299647f2aa59775937;hpb=f4ebd2a21332264d998d5fad8b7e5e86dd889862;p=friendica.git diff --git a/mod/salmon.php b/mod/salmon.php index 8c7d921c86..300ad87466 100644 --- a/mod/salmon.php +++ b/mod/salmon.php @@ -1,14 +1,11 @@ encoding; $alg = $base->alg; - // If we're talking to status.net or one of their ilk, they aren't following the magic envelope spec - // and only signed the data element. We'll be nice and let them validate anyway. + // Salmon magic signatures have evolved and there is no way of knowing ahead of time which + // flavour we have. We'll try and verify it regardless. $stnet_signed_data = $data; + $signed_data = $data . '.' . base64url_encode($type) . '.' . base64url_encode($encoding) . '.' . base64url_encode($alg); + $compliant_format = str_replace('=','',$signed_data); + + // decode the data $data = base64url_decode($data); @@ -89,7 +90,7 @@ function salmon_post(&$a) { // Create a fake feed wrapper so simplepie doesn't choke - $tpl = load_view_file('view/fake_feed.tpl'); + $tpl = get_markup_template('fake_feed.tpl'); $base = substr($data,strpos($data,'exponent = new Math_BigInteger($e, 256); // We should have everything we need now. Let's see if it verifies. - // If it fails with the proper data format, try again using just the data - // (e.g. status.net) - $verify = $rsa->verify($signed_data,$signature); + $verify = $rsa->verify($compliant_format,$signature); if(! $verify) { - logger('mod-salmon: message did not verify using protocol. Trying statusnet hack.'); + logger('mod-salmon: message did not verify using protocol. Trying padding hack.'); + $verify = $rsa->verify($signed_data,$signature); + } + + if(! $verify) { + logger('mod-salmon: message did not verify using padding. Trying old statusnet hack.'); $verify = $rsa->verify($stnet_signed_data,$signature); } @@ -177,7 +181,7 @@ function salmon_post(&$a) { * */ - $r = q("SELECT * FROM `contact` WHERE `network` = 'stat' AND ( `url` = '%s' OR `lrdd` = '%s') + $r = q("SELECT * FROM `contact` WHERE `network` = 'stat' AND ( `url` = '%s' OR `alias` = '%s') AND `uid` = %d LIMIT 1", dbesc($author_link), dbesc($author_link), @@ -186,7 +190,11 @@ function salmon_post(&$a) { if(! count($r)) { logger('mod-salmon: Author unknown to us.'); } - if((count($r)) && ($r[0]['readonly'])) { + + // is this a follower? Or have we ignored the person? + // If so we can not accept this post. + + if((count($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == REL_VIP) || ($r[0]['blocked']))) { logger('mod-salmon: Ignoring this author.'); salmon_return(202); // NOTREACHED