]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
CSRF protection in newmessage.php
authorEvan Prodromou <evan@controlyourself.ca>
Tue, 23 Sep 2008 03:14:19 +0000 (23:14 -0400)
committerEvan Prodromou <evan@controlyourself.ca>
Tue, 23 Sep 2008 03:14:19 +0000 (23:14 -0400)
darcs-hash:20080923031419-5ed1f-5435509496b882de27d4c3acca4697cc410ee7be.gz

actions/newmessage.php

index 5aa3633234f3a74b1bde58f5e9f96e5c68da9818..e223ed8ff74e0ad6a30836199151a875aa56d7ac 100644 (file)
@@ -37,6 +37,14 @@ class NewmessageAction extends Action {
 
                $user = common_current_user();
                assert($user); # XXX: maybe an error instead...
+
+               # 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;
+               }
                
                $content = $this->trimmed('content');
                $to = $this->trimmed('to');
@@ -117,6 +125,8 @@ class NewmessageAction extends Action {
                                                                          'type' => 'submit',
                                                                          'value' => _('Send')));
                
+               common_hidden('token', common_session_token());
+               
                common_element_end('p');
                common_element_end('form');
        }