58 $this->mRegex = $regex;
59 $this->mParams = $params;
68 global $wgTitleBlacklistUsernameSources;
70 if ( $wgTitleBlacklistUsernameSources ===
'*' ) {
74 if ( !$wgTitleBlacklistUsernameSources ) {
78 if ( !is_array( $wgTitleBlacklistUsernameSources ) ) {
80 '$wgTitleBlacklistUsernameSources must be "*", false or an array' );
83 return in_array( $this->mSource, $wgTitleBlacklistUsernameSources,
true );
103 if ( isset( $this->mParams[
'antispoof'] )
104 && is_callable(
'AntiSpoof::checkUnicodeString' )
106 if ( $action ===
'edit' ) {
108 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
109 list( $ok, $norm ) =
$cache->getWithSetCallback(
110 $cache->makeKey(
'titleblacklist',
'normalized-unicode', md5(
$title ) ),
112 function () use (
$title ) {
113 return AntiSpoof::checkUnicodeString(
$title );
115 [
'pcTTL' => $cache::TTL_PROC_LONG ]
118 list( $ok, $norm ) = AntiSpoof::checkUnicodeString(
$title );
121 if ( $ok ===
"OK" ) {
122 list( ,
$title ) = explode(
':', $norm, 2 );
124 wfDebugLog(
'TitleBlacklist',
'AntiSpoof could not normalize "' .
$title .
'".' );
128 Wikimedia\suppressWarnings();
130 "/^(?:{$this->mRegex})$/us" . ( isset( $this->mParams[
'casesensitive'] ) ?
'' :
'i' ),
133 Wikimedia\restoreWarnings();
136 if ( isset( $this->mParams[
'moveonly'] ) && $action !=
'move' ) {
139 if ( isset( $this->mParams[
'newaccountonly'] ) && $action !=
'new-account' ) {
142 if ( !isset( $this->mParams[
'noedit'] ) && $action ==
'edit' ) {
145 if ( isset( $this->mParams[
'reupload'] ) && $action ==
'upload' ) {
166 $line = preg_replace(
"/^\\s*([^#]*)\\s*((.*)?)$/",
"\\1",
$line );
169 if (
$line ===
'' ) {
174 if ( !preg_match(
'/^(.*?)(\s*<([^<>]*)>)?$/',
$line, $pockets ) ) {
177 $regex = trim( $pockets[1] );
178 $regex = str_replace(
'_',
' ', $regex );
179 $opts_str = isset( $pockets[3] ) ? trim( $pockets[3] ) :
'';
181 $opts = preg_split(
'/\s*\|\s*/', $opts_str );
182 foreach ( $opts as $opt ) {
183 $opt2 = strtolower( $opt );
184 if ( $opt2 ==
'autoconfirmed' ) {
185 $options[
'autoconfirmed'] =
true;
187 if ( $opt2 ==
'moveonly' ) {
188 $options[
'moveonly'] =
true;
190 if ( $opt2 ==
'newaccountonly' ) {
191 $options[
'newaccountonly'] =
true;
193 if ( $opt2 ==
'noedit' ) {
194 $options[
'noedit'] =
true;
196 if ( $opt2 ==
'casesensitive' ) {
197 $options[
'casesensitive'] =
true;
199 if ( $opt2 ==
'reupload' ) {
200 $options[
'reupload'] =
true;
202 if ( preg_match(
'/errmsg\s*=\s*(.+)/i', $opt,
$matches ) ) {
205 if ( $opt2 ==
'antispoof' ) {
206 $options[
'antispoof'] =
true;
210 preg_match_all(
'/{{\s*([a-z]+)\s*:\s*(.+?)\s*}}/', $regex, $magicwords, PREG_SET_ORDER );
211 foreach ( $magicwords as $mword ) {
213 switch ( strtolower( $mword[1] ) ) {
216 if ( is_string( $cpf_result ) ) {
218 $regex = str_replace( $mword[0], $cpf_result, $regex );
222 $cpf_result =
wfMessage( $mword[2] )->inContentLanguage()->text();
223 if ( is_string( $cpf_result ) ) {
224 $regex = str_replace( $mword[0], $cpf_result, $regex );
261 return $this->mParams[
'errmsg'] ??
null;
277 $this->mFormatVersion = $v;
292 return $message ?:
"titleblacklist-forbidden-{$operation}";