From a034e13bf03fe06cf5d2500bd29506c71c67b6bb Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 29 Aug 2008 01:33:37 -0400 Subject: [PATCH] CSRF protection in emailsettings darcs-hash:20080829053337-7b5ce-6d94638c57d185e5d44e02ad458593a3f4de36d9.gz --- actions/emailsettings.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/actions/emailsettings.php b/actions/emailsettings.php index 5e2c06bbd3..c93cbfae0d 100644 --- a/actions/emailsettings.php +++ b/actions/emailsettings.php @@ -34,6 +34,7 @@ class EmailsettingsAction extends SettingsAction { 'id' => 'emailsettings', 'action' => common_local_url('emailsettings'))); + common_hidden('token', common_session_token()); common_element('h2', NULL, _('Address')); @@ -114,6 +115,13 @@ class EmailsettingsAction 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; + } + if ($this->arg('save')) { $this->save_preferences(); } else if ($this->arg('add')) {