From c1f9b1f7b1b77776192048005dcc66dcf3df2bfb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 27 Dec 2014 15:41:37 +0100 Subject: Update to MediaWiki 1.24.1 --- extensions/TitleBlacklist/TitleBlacklist.list.php | 53 +++++++++++++++++------ 1 file changed, 39 insertions(+), 14 deletions(-) (limited to 'extensions/TitleBlacklist/TitleBlacklist.list.php') diff --git a/extensions/TitleBlacklist/TitleBlacklist.list.php b/extensions/TitleBlacklist/TitleBlacklist.list.php index d197a9c5..3947e8ae 100644 --- a/extensions/TitleBlacklist/TitleBlacklist.list.php +++ b/extensions/TitleBlacklist/TitleBlacklist.list.php @@ -156,7 +156,12 @@ class TitleBlacklist { if ( $override && self::userCanOverride( $user, $action ) ) { return false; } else { - return $this->isBlacklisted( $title, $action ); + $entry = $this->isBlacklisted( $title, $action ); + if ( !$entry ) { + return false; + } + $params = $entry->getParams(); + return isset( $params['autoconfirmed'] ) && $user->isAllowed( 'autoconfirmed' ) ? false : $entry; } } @@ -172,17 +177,29 @@ class TitleBlacklist { public function isBlacklisted( $title, $action = 'edit' ) { if ( !( $title instanceof Title ) ) { $title = Title::newFromText( $title ); + if ( !( $title instanceof Title ) ) { + // The fact that the page name is invalid will stop whatever + // action is going through. No sense in doing more work here. + return false; + } } $blacklist = $this->getBlacklist(); + $autoconfirmedItem = false; foreach ( $blacklist as $item ) { - if ( $item->matches( $title, $action ) ) { + if ( $item->matches( $title->getFullText(), $action ) ) { if ( $this->isWhitelisted( $title, $action ) ) { return false; } - return $item; // "returning true" + $params = $item->getParams(); + if ( !isset( $params['autoconfirmed'] ) ) { + return $item; + } + if ( !$autoconfirmedItem ) { + $autoconfirmedItem = $item; + } } } - return false; + return $autoconfirmedItem; } /** @@ -199,7 +216,7 @@ class TitleBlacklist { } $whitelist = $this->getWhitelist(); foreach ( $whitelist as $item ) { - if ( $item->matches( $title, $action ) ) { + if ( $item->matches( $title->getFullText(), $action ) ) { return true; } } @@ -343,7 +360,7 @@ class TitleBlacklistEntry { * Check whether a user can perform the specified action * on the specified Title * - * @param $title Title to check + * @param $title string to check * @param $action %Action to check * @return bool TRUE if the the regex matches the title, and is not overridden * else false if it doesn't match (or was overridden) @@ -357,15 +374,20 @@ class TitleBlacklistEntry { return false; } + if ( isset( $this->mParams['antispoof'] ) && is_callable( 'AntiSpoof::checkUnicodeString' ) ) { + list( $ok, $norm ) = AntiSpoof::checkUnicodeString( $title ); + if ( $ok == "OK" ) { + list( $ver, $title ) = explode( ':', $norm, 2 ); + } else { + wfDebugLog( 'TitleBlacklist', 'AntiSpoof could not normalize "' . $title . '".' ); + } + } + wfSuppressWarnings(); - $match = preg_match( "/^(?:{$this->mRegex})$/us" . ( isset( $this->mParams['casesensitive'] ) ? '' : 'i' ), $title->getFullText() ); + $match = preg_match( "/^(?:{$this->mRegex})$/us" . ( isset( $this->mParams['casesensitive'] ) ? '' : 'i' ), $title ); wfRestoreWarnings(); - global $wgUser; if ( $match ) { - if ( isset( $this->mParams['autoconfirmed'] ) && $wgUser->isAllowed( 'autoconfirmed' ) ) { - return false; - } if ( isset( $this->mParams['moveonly'] ) && $action != 'move' ) { return false; } @@ -427,6 +449,9 @@ class TitleBlacklistEntry { if ( preg_match( '/errmsg\s*=\s*(.+)/i', $opt, $matches ) ) { $options['errmsg'] = $matches[1]; } + if ( $opt2 == 'antispoof' ) { + $options['antispoof'] = true; + } } // Process magic words preg_match_all( '/{{\s*([a-z]+)\s*:\s*(.+?)\s*}}/', $regex, $magicwords, PREG_SET_ORDER ); @@ -469,10 +494,10 @@ class TitleBlacklistEntry { } /** - * @return array This entry's options + * @return array This entry's parameters */ - public function getOptions() { - return $this->mOptions; + public function getParams() { + return $this->mParams; } /** -- cgit v1.2.2