SECURITY: Add data attribute to patrol links so it can't be spoofed by user
authorBrian Wolff <bawolff+wn@gmail.com>
Tue, 27 Oct 2015 08:31:00 +0000 (02:31 -0600)
committerChad Horohoe <chadh@wikimedia.org>
Fri, 20 May 2016 16:25:35 +0000 (09:25 -0700)
Javascript used to look just for the patrollinks class, which
could be set by the user in order to patrol an arbitrary page.

Bug: T103239
Change-Id: I13fcc3ce479c0a4a90a6217c2e5244f051eaf862

Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
includes/diff/DifferenceEngine.php
includes/page/Article.php
resources/src/mediawiki/page/patrol.ajax.js

index e2345ca..caef7f1 100644 (file)
@@ -474,7 +474,7 @@ class DifferenceEngine extends ContextSource {
                        if ( !$linkInfo ) {
                                $this->mMarkPatrolledLink = '';
                        } else {
-                               $this->mMarkPatrolledLink = ' <span class="patrollink">[' . Linker::linkKnown(
+                               $this->mMarkPatrolledLink = ' <span class="patrollink" data-mw="interface">[' . Linker::linkKnown(
                                        $this->mNewPage,
                                        $this->msg( 'markaspatrolleddiff' )->escaped(),
                                        [],
index 4c9eaed..eccf36f 100644 (file)
@@ -1216,7 +1216,7 @@ class Article implements Page {
                );
 
                $outputPage->addHTML(
-                       "<div class='patrollink'>" .
+                       "<div class='patrollink' data-mw='interface'>" .
                                wfMessage( 'markaspatrolledlink' )->rawParams( $link )->escaped() .
                        '</div>'
                );
index ec68b3c..e78bd4e 100644 (file)
@@ -12,7 +12,7 @@
                return;
        }
        $( function () {
-               var $patrolLinks = $( '.patrollink a' );
+               var $patrolLinks = $( '.patrollink[data-mw="interface"] a' );
                $patrolLinks.on( 'click', function ( e ) {
                        var $spinner, rcid, apiRequest;