]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
CSRF protection in imsettings.php
authorZach Copley <zach@controlyourself.ca>
Fri, 29 Aug 2008 03:57:07 +0000 (23:57 -0400)
committerZach Copley <zach@controlyourself.ca>
Fri, 29 Aug 2008 03:57:07 +0000 (23:57 -0400)
darcs-hash:20080829035707-7b5ce-69a9ff98390ff8b9671ede948d78fdb37371aac6.gz

actions/imsettings.php

index 034f6dc2b284518ef50e6e3bae1416403ef180be..0aa7631dc2c2fc59314ce269aad42cf65a4985cb 100644 (file)
@@ -35,6 +35,7 @@ class ImsettingsAction extends SettingsAction {
                                                                                   'id' => 'imsettings',
                                                                                   'action' =>
                                                                                   common_local_url('imsettings')));
+               common_hidden('token', common_session_token());
 
                common_element('h2', NULL, _('Address'));
 
@@ -98,6 +99,13 @@ class ImsettingsAction 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')) {