From 6c4dc071bffd16c0a1da8382bc6e854841f1b6d1 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 29 Aug 2008 00:57:24 -0400 Subject: [PATCH] CSRF protection in twittersettings.php darcs-hash:20080829045724-7b5ce-66fdc5e54155012e41eb09c6a41bc94619bf520f.gz --- actions/twittersettings.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/actions/twittersettings.php b/actions/twittersettings.php index 592c9347f6..dac0ce2000 100644 --- a/actions/twittersettings.php +++ b/actions/twittersettings.php @@ -43,6 +43,7 @@ class TwittersettingsAction extends SettingsAction { 'id' => 'twittersettings', 'action' => common_local_url('twittersettings'))); + common_hidden('token', common_session_token()); if ($fuser) { common_element_start('p'); @@ -83,6 +84,14 @@ class TwittersettingsAction 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')) { -- 2.39.5