X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fremotesubscribe.php;h=7137b42a26f79749a881c72b6999f5b8f73e2da1;hb=485247e9011e08a6ff0b9a2ff3d7a60bad515a26;hp=d1baa4152f6c1a82db8c9ffbbd5c122473d0cea8;hpb=3a262a3bcd0c794f12d97b28be33b1c262063718;p=quix0rs-gnu-social.git diff --git a/actions/remotesubscribe.php b/actions/remotesubscribe.php index d1baa4152f..7137b42a26 100644 --- a/actions/remotesubscribe.php +++ b/actions/remotesubscribe.php @@ -33,6 +33,14 @@ class RemotesubscribeAction extends Action { } if ($_SERVER['REQUEST_METHOD'] == 'POST') { + + # CSRF protection + $token = $this->trimmed('token'); + if (!$token || $token != common_session_token()) { + $this->show_form(_('There was a problem with your session token. Try again, please.')); + return; + } + $this->remote_subscription(); } else { $this->show_form(); @@ -68,6 +76,7 @@ class RemotesubscribeAction extends Action { # button on profile page common_element_start('form', array('id' => 'remsub', 'method' => 'post', 'action' => common_local_url('remotesubscribe'))); + common_hidden('token', common_session_token()); common_input('nickname', _('User nickname'), $nickname, _('Nickname of the user you want to follow')); common_input('profile_url', _('Profile URL'), $profile, @@ -105,7 +114,9 @@ class RemotesubscribeAction extends Action { return; } - $xrds =& Auth_Yadis_XRDS::parseXRDS($yadis->response_text); + # XXX: a little liberal for sites that accidentally put whitespace before the xml declaration + + $xrds =& Auth_Yadis_XRDS::parseXRDS(trim($yadis->response_text)); if (!$xrds) { $this->show_form(_('Not a valid profile URL (no XRDS defined).')); @@ -302,7 +313,14 @@ class RemotesubscribeAction extends Action { $req->set_parameter('omb_listenee_profile', common_profile_url($user->nickname)); $req->set_parameter('omb_listenee_nickname', $user->nickname); $req->set_parameter('omb_listenee_license', $config['license']['url']); + $profile = $user->getProfile(); + if (!$profile) { + common_log_db_error($user, 'SELECT', __FILE__); + $this->server_error(_('User without matching profile')); + return; + } + if ($profile->fullname) { $req->set_parameter('omb_listenee_fullname', $profile->fullname); }