FANDOM


MediaWiki extensions manual - list
TitleBlacklist

Release status: stable

Implementation User rights, API
Description Block the creation of pages matching a regular expression blacklist
Author(s) Victor Vasiliev (VasilievVVTalk)
Last version v1.4.2 (2008-08-05)
MediaWiki 1.12+
Database changes<abbr/> no
License GPL v2+
Download
Parameters
  • $wgTitleBlacklistSources
Added rights
  • tboverride
  • tboverride-account
Hooks used
getUserPermissionsErrorsExpensive

AbortMove
AbortNewAccount
AbortAutoAccount
EditFilter
ArticleSaveComplete
UserCreateForm

Check usage and version matrix

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.

Requirements Edit

Extension requires MediaWiki 1.12.0 or above (it needs AbortMove hook).

DownloadEdit

You can download the extension directly from the MediaWiki source code repository (browse code). You can get:

One of the extensions tags

Not all extensions have tags. Some extensions have tags for each release, in which case those tags have the same stability as the release. To download a tag

  • Go to the tags list
  • Click the name of the tag you want to download
  • Click "snapshot"
The latest version of one of the extensions branches

Each extension has a master branch containing the latest code (might be unstable). Extensions can have further branches as well.

  • Go to the branches list
  • Click the branch name
  • Click "snapshot"
A snapshot made during the release of a MediaWiki version.

This might be unstable and is not guaranteed to work with the associated MediaWiki version.

After you've got the code, save it into the extensions/Extension:TitleBlacklist directory of your wiki.

If you are familiar with git and have shell access to your server, you can obtain the extension, with all its tags and branches, as follows:

cd extensions
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Extension%3ATitleBlacklist.git


Installation Edit

  1. Add the line
    require_once( "$IP/extensions/TitleBlacklist/TitleBlacklist.php" );
    to your LocalSettings.php file
  2. Configure blacklist sources (see below)

Installation can be verified through the Special:Version page on the wiki.

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

Multiple blacklist sources Edit

Title blacklist can be gathered from multiple sources except local message. For configuring blacklist sources use code like this:

$wgTitleBlacklistSources = array(
    array(
         'type' => TBLSRC_LOCALPAGE,
         'src'  => 'MediaWiki:Titleblacklist',
    ),
    array(
         'type' => TBLSRC_URL,
         'src'  => 'http://meta.wikimedia.org/w/index.php?title=Title_blacklist&action=raw',
    ),
    array(
         'type' => TBLSRC_FILE,
         'src'  => '/home/wikipedia/blacklists/titles',
    ),
);
  • Use TBLSRC_LOCALPAGE for using local page as title blacklist
  • Use TBLSRC_URL for using external URL as title blacklist
  • Use TBLSRC_FILE for using file as title blacklist

Editing the blacklist Edit

The title blacklist is found on the MediaWiki:Titleblacklist page.

This page consists of regular expressions, each on a separate line, for example:

Foo <autoconfirmed|noedit|errmsg=blacklisted-testpage> 
[Bb]ar #No one should create article about it

Each entry may also contain optional attributes, enclosed in <> and separated with |

  • autoconfirmed - only autoconfirmed users are able to create/upload/move such pages
  • casesensitive - don't ignore case when checking title for being blacklisted
  • noedit - users are also unable to edit this article
  • moveonly - forbid moves but allow ordinary creation (rev:35163)
  • newaccountonly - forbid creation of matching usernames, but allow page creation (rev:38977)
  • reupload - allow reuploads of existing blacklisted files (rev:33656)
  • errmsg - the name of the message that should be displayed instead of standard

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 Edit

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.

Customising warning messages Edit

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 customised via system messages

Custom messages can be defined by using the errmsg attribute.

Using TitleBlacklist to control user account creation Edit

Conceptual overview Edit

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.

If you want to block all users except for all those that do match a regex then block all users in MediaWiki:Titleblacklist and write the permissible regex in the MediaWiki:Titlewhitelist.

A working example Edit

If you would like to force all usernames, during account creation, to consist of exactly two names, space separated, with each name capitalized then do the following:

1. Install TitleBlacklist.

2. Add the following to your LocalSettings.php

require_once( "{$IP}/extensions/TitleBlacklist/TitleBlacklist.php" );
// Apply to all, not just anonymous users.
$wgGroupPermissions['sysop']['tboverride'] = false; 
$wgTitleBlacklistSources = array(
  array(
    'type' => TBLSRC_LOCALPAGE,
    'src'  => 'MediaWiki:Titleblacklist'
  )
);

3. In https://www.example.com/mywiki/MediaWiki:Titleblacklist add

# Block all user accounts, and only permit those that match the MediaWiki:Titlewhitelistregex 
.* <newaccountonly>

4. In https://www.example.com/mywiki/MediaWiki:Titlewhitelist add

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

5. In https://www.example.com/mywiki/MediaWiki:Titleblacklist-forbidden-new-account edit

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 capitalised.<br />
 
E.g.:
* "Mary Smith". OK.
* "MarySmith". Invalid.
* "Mary smith". Invalid.
* "marysmith". Invalid.
 
User name creation (and article creation) blocking rules are controlled by [[MediaWiki:Titleblacklist]] and [[MediaWiki:Titlewhitelist]]. 
This message can be customised at [[MediaWiki:Titleblacklist-forbidden-new-account]]

Change log Edit

A complete log of changes to the extension code (including internationalisation updates from third parties) is available from the Subversion log, however, summarised information on changes between point releases is given below:

Version Revision Release Date Comments
1.4.2 38636 2008-08-05
1.4.1 31074 2008-02-18
1.4 28866 2007-12-26
1.3 28657 2007-12-19 Check for blacklist validity before saving
1.2 28504 2007-12-15 Cleaned up version with caching support
1.1 28362 2007-12-10 New version with support of entry attributes and multiple sources
1.0 27208 2007-11-05 Initial version

Resources on regular expressions Edit


See also Edit

Language: English

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.