From: Evan Prodromou Date: Fri, 29 Aug 2008 02:39:19 +0000 (-0400) Subject: add CSRF protection to avatar X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d3c86d00163bba1a57d1f597995721b8badbce62;p=quix0rs-gnu-social.git add CSRF protection to avatar darcs-hash:20080829023919-84dde-38e4bf6bddc120a221af5f856d9f88b7a532096b.gz --- diff --git a/actions/avatar.php b/actions/avatar.php index ebfbd72952..9f397e93c3 100644 --- a/actions/avatar.php +++ b/actions/avatar.php @@ -58,6 +58,7 @@ class AvatarAction extends SettingsAction { 'id' => 'avatar', 'action' => common_local_url('avatar'))); + common_hidden('token', common_session_token()); common_element('input', array('name' => 'MAX_FILE_SIZE', 'type' => 'hidden', 'id' => 'MAX_FILE_SIZE', @@ -72,6 +73,14 @@ class AvatarAction extends SettingsAction { function handle_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; + } + switch ($_FILES['avatarfile']['error']) { case UPLOAD_ERR_OK: # success, jump out break;