The TitleBlacklist extension allows wiki administrators to block the creation, movement and upload of pages, the title of which matches one or more regular expressions, as well as blocking creation of accounts with matching usernames.

Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

By default it only affects non-sysop users. To make it default for all use $wgGroupPermissions['sysop']['tboverride'] = false;.

Configuration

$wgTitleBlacklistSources

Array of title blacklist sources.

Should be in array( name => source description ) format. Defaults to an empty array.

$wgTitleBlacklistUsernameSources

Sets the sources which may work as a username filter.

'*' is for all; false disables all.

If you want to limit it to particular sources, use array( source name 1, source name 2 ). This may be useful when you have shared account creation system in order to avoid blacklist fragmentation.

$wgTitleBlacklistLogHits

When true, logs on Special:Log/Titleblacklist all attempts of local account creation that match the blacklists. Defaults to false. Note that even disabled, the log will still be visible for users groups with the titleblacklistlog right.

$wgTitleBlacklistCaching

?

$wgTitleBlacklistBlockAutoAccountCreation

Also blocks account created automatically that match the blacklists. Defaults to true.

Multiple blacklist sources

The Title blacklist can be gathered from multiple sources outside the local message. For configuring blacklist sources use code as described below:

errmsg - the name of the message that should be displayed instead of standard

If the AntiSpoof extension is installed, you can also use the <antispoof> attribute.

What is referred to here as regular expressions are not proper regular expressions, but rather subpatterns that are inserted into a hard-coded regular expression. i.e. the subpattern Foo from above would create a regular expression like /^Foo$/usi.

Underscores ("_") in regular expressions will be converted to spaces by the extension, because titles are matched against its text form ("Page title" instead of "Page_title").

Whitelist

There is also a whitelist at MediaWiki:Titlewhitelist. The blacklist is applied first, then the whitelist. So user input that matches an entry on the blacklist is blocked, except if it matches an entry on the whitelist. You don't have to configure anything in LocalSettings.php in order to use the whitelist. Some of the optional attributes listed above, for the blacklist, also work for the whitelist, e.g. casesensitive.

Customizing

Warning messages

When an attempt to create a page is blocked due to a blacklisted title, a warning message is shown to the user. This can be customized via system messages

Example: Using TitleBlacklist to control user account creation

Conceptual overview

The username for new accounts will be regarded by Titleblacklist differently to the way it regards new articles. Titleblacklist will prepend "User:" (or its localized equivalent) to the string that a user enters at Username on the create account page. So when Titleblacklist is performing matches with your Regex's, as found on MediaWiki:Titleblacklist or MediaWiki:Titlewhitelist, it will match against "User:" + <userinput>.

For example, imagine you want to block "jill" as a new user. Imagine you had a blacklist regex "jill.* <newaccountonly>" and a user enters "jill" as the username on the create account page. This will pass as the comparison Titleblacklist will make will be between "jill.*" (the regex) and "User:jill" (the constructed input string). These don't match and so "jill" is allowed (and you probably didn't intend this). To effect the intended block use a regex like ".*jill.* <newaccountonly>" or "User:jill.* <newaccountonly>" on MediaWiki:Titleblacklist.

# Only allow two names, separated by a space, with each name capitalized. E.g "Fred Mew" OK, "Fred mew" fails, "Fredmew" fails.# Depends on .* <newaccountonly> in blacklistUser:[A-Z][a-z]+\s[A-Z][a-z]+<casesensitive>

The user name "$2" has been blocked from creation. It matches the following blacklist entry: <code>$1</code>.
Please use a real name for the user name. User names need to be comprised of two names separated by a space. Each name must be capitalized.
E.g.:
* "Mary Smith". OK.
* "MarySmith". Invalid.
* "Mary smith". Invalid.
* "marysmith". Invalid.

Testing for matches

The API module action=titleblacklist can be used to test a title and action (e.g. edit, create, new-account) against the blacklist.
Users with the 'tboverride' right should be sure to supply the tbnooverride parameter.

For example, if the blacklist contained the filter:

.*(.)\1{10}.* <newaccountonly|errmsg=titleblacklist-forbidden-new-account-invalid> # Disallows eleven or more of the same character repeated in usernames

{"titleblacklist":{"result":"blacklisted","reason":"<table class=\"plainlinks fmbox\nfmbox-system \" style=\"\" role=\"presentation\" dir=\"ltr\">\n<tr>\n<td class=\"mbox-image\">\n [[File:Imbox notice.png|40x40px|link=|alt=]]</td>\n<td class=\"mbox-text\" style=\"\"> The user name \"AAAAAAAAAAA\" [[Mediawiki talk:Titleblacklist|has been blacklisted]] from creation. </td>\n\n</tr>\n</table>","message":"titleblacklist-forbidden-new-account-invalid","line":".*(.)\1{10}.* &lt;newaccountonly|errmsg=titleblacklist-forbidden-new-account-invalid&gt; # Disallows eleven or more of the same character repeated in usernames"}}

If Scribunto is installed, TitleBlacklist allows for testing if particular titles and actions will match an entry in the blacklist using the mw.ext.TitleBlacklist.test function.
If a match is found, the details for the matched entry are returned.

For example, if the blacklist contained the filter:

.*(.)\1{10}.* <newaccountonly|errmsg=titleblacklist-forbidden-new-account-invalid> # Disallows eleven or more of the same character repeated in usernames

running the function:

mw.ext.TitleBlacklist.test("new-account","AAAAAAAAAAA")

would return the following table containing details about the matched entry:

{custommessage="titleblacklist-forbidden-new-account-invalid",message="titleblacklist-forbidden-new-account-invalid",params={errmsg="titleblacklist-forbidden-new-account-invalid",newaccountonly=true},raw=" .*(.)\1{10}.* <newaccountonly|errmsg=titleblacklist-forbidden-new-account-invalid> # Disallows eleven or more of the same character repeated in usernames",regex=".*(.)\1{10}.*",version=3}

Vedi anche

This extension is being used on one or more Wikimedia projects. This probably means that the extension is stable and works well enough to be used by such high-traffic websites. Look for this extension's name in Wikimedia's CommonSettings.php and InitialiseSettings.php configuration files to see where it's installed. A full list of the extensions installed on a particular wiki can be seen on the wiki's Special:Version page.