summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-08-28 22:39:19 -0400
committerEvan Prodromou <evan@prodromou.name>2008-08-28 22:39:19 -0400
commitd3c86d00163bba1a57d1f597995721b8badbce62 (patch)
treef812a2a3da61cab45f5e6c79776edaff1b061fb9 /actions
parentd146355875da9cf2a3f9390bb4601033b2ea2bc3 (diff)
add CSRF protection to avatar
darcs-hash:20080829023919-84dde-38e4bf6bddc120a221af5f856d9f88b7a532096b.gz
Diffstat (limited to 'actions')
-rw-r--r--actions/avatar.php9
1 files changed, 9 insertions, 0 deletions
diff --git a/actions/avatar.php b/actions/avatar.php
index ebfbd7295..9f397e93c 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;