From 8a66b3cc4a36bcbfc2aa1be261f3183c8ea668b2 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Thu, 28 Jun 2007 22:34:36 +0000 Subject: [PATCH] * Fix read permission check for special pages with subpage parameters, e.g. Special:Confirmemail * Fix read permission check for page titles consisting of one or more zeros, e.g. "0", "00" etc. --- RELEASE-NOTES | 4 ++++ includes/Title.php | 34 +++++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 80f357ffdd..3f218b54f4 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -234,6 +234,10 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 10401) Provide non-redirecting link to original title in Special:Movepage * Fix broken handling of log views for page titles consisting of one or more zeros, e.g. "0", "00" etc. +* Fix read permission check for special pages with subpage parameters, e.g. + Special:Confirmemail +* Fix read permission check for page titles consisting of one or more zeros, + e.g. "0", "00" etc. == API changes since 1.10 == diff --git a/includes/Title.php b/includes/Title.php index 8a21ab3954..dcb87901b9 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1148,7 +1148,7 @@ class Title { return $result; } - if( $wgUser->isAllowed('read') ) { + if( $wgUser->isAllowed( 'read' ) ) { return true; } else { global $wgWhitelistRead; @@ -1160,19 +1160,35 @@ class Title { if( $this->isSpecial( 'Userlogin' ) || $this->isSpecial( 'Resetpass' ) ) { return true; } - - /** some pages are explicitly allowed */ + + /** + * Check for explicit whitelisting + */ $name = $this->getPrefixedText(); - if( $wgWhitelistRead && in_array( $name, $wgWhitelistRead ) ) { + if( $wgWhitelistRead && in_array( $name, $wgWhitelistRead, true ) ) return true; - } - - # Compatibility with old settings + + /** + * Old settings might have the title prefixed with + * a colon for main-namespace pages + */ if( $wgWhitelistRead && $this->getNamespace() == NS_MAIN ) { - if( in_array( ':' . $name, $wgWhitelistRead ) ) { + if( in_array( ':' . $name, $wgWhitelistRead ) ) return true; - } } + + /** + * If it's a special page, ditch the subpage bit + * and check again + */ + if( $this->getNamespace() == NS_SPECIAL ) { + $name = $this->getText(); + list( $name, $subpage ) = SpecialPage::resolveAliasWithSubpage( $name ); + $pure = SpecialPage::getTitleFor( $name )->getPrefixedText(); + if( in_array( $pure, $wgWhitelistRead, true ) ) + return true; + } + } return false; } -- 2.20.1