r40805 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40804‎ | r40805 | r40806 >
Date:01:44, 14 September 2008
Author:krimpet
Status:old
Tags:
Comment:
Block redirects to blacklisted nonexistent titles as well.
Modified paths:
  • /trunk/extensions/TitleBlacklist/TitleBlacklist.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/TitleBlacklist/TitleBlacklist.hooks.php
@@ -84,27 +84,44 @@
8585 global $wgTitleBlacklist;
8686 efInitTitleBlacklist();
8787 $title = $editor->mTitle;
88 - if( $title->getNamespace() != NS_MEDIAWIKI || $title->getDBkey() != 'Titleblacklist' )
 88+ if( $title->getNamespace() == NS_MEDIAWIKI && $title->getDBkey() == 'Titleblacklist' ) {
 89+
 90+ $bl = $wgTitleBlacklist->parseBlacklist( $text );
 91+ $ok = $wgTitleBlacklist->validate( $bl );
 92+ if( count( $ok ) == 0 ) {
 93+ return true;
 94+ }
 95+
 96+ wfLoadExtensionMessages( 'TitleBlacklist' );
 97+ $errmsg = wfMsgExt( 'titleblacklist-invalid', array( 'parsemag' ), count( $ok ) );
 98+ $errlines = '* <tt>' . implode( "</tt>\n* <tt>", array_map( 'wfEscapeWikiText', $ok ) ) . '</tt>';
 99+ $error = '<div class="errorbox">' .
 100+ $errmsg .
 101+ "\n" .
 102+ $errlines .
 103+ "</div>\n" .
 104+ "<br clear='all' />\n";
 105+
 106+ // $error will be displayed by the edit class
89107 return true;
 108+ } else if (!$section) {
 109+ # Block redirects to nonexistent blacklisted titles
 110+ $retitle = Title::newFromRedirect( $text );
 111+ if ( $retitle !== null && !$retitle->exists() ) {
 112+ $blacklisted = $wgTitleBlacklist->isBlacklisted( $retitle, 'create' );
 113+ if ( $blacklisted instanceof TitleBlacklistEntry ) {
 114+ wfLoadExtensionMessages( 'TitleBlacklist' );
 115+ $error = ( '<div class="errorbox">' .
 116+ wfMsg( 'titleblacklist-forbidden-edit',
 117+ htmlspecialchars( $blacklisted->getRaw() ),
 118+ $retitle->getFullText() ) .
 119+ "</div>\n" .
 120+ "<br clear='all' />\n" );
 121+ }
 122+ }
90123
91 - $bl = $wgTitleBlacklist->parseBlacklist( $text );
92 - $ok = $wgTitleBlacklist->validate( $bl );
93 - if( count( $ok ) == 0 ) {
94124 return true;
95125 }
96 -
97 - wfLoadExtensionMessages( 'TitleBlacklist' );
98 - $errmsg = wfMsgExt( 'titleblacklist-invalid', array( 'parsemag' ), count( $ok ) );
99 - $errlines = '* <tt>' . implode( "</tt>\n* <tt>", array_map( 'wfEscapeWikiText', $ok ) ) . '</tt>';
100 - $error = '<div class="errorbox">' .
101 - $errmsg .
102 - "\n" .
103 - $errlines .
104 - "</div>\n" .
105 - "<br clear='all' />\n";
106 -
107 - // $error will be displayed by the edit class
108 - return true;
109126 }
110127
111128 /** ArticleSaveComplete hook */