This page is a translated version of the page Extension:TitleBlacklist and the translation is 65% complete.
Other languages:
Deutsch • ‎English • ‎Tiếng Việt • ‎español • ‎polski • ‎português do Brasil • ‎čeština • ‎беларуская (тарашкевіца)‎ • ‎中文 • ‎日本語 • ‎한국어
此扩展已绑定在MediaWiki 1.21及以上版本 因此您不需要再次下载。 然而,您仍需要跟随提供的其他指示。
OOjs UI icon advanced.svg
发布状态: 稳定版
TitleBlacklist demonstration.png
实现 用户权限 , API
描述 禁止建立與正規表達式黑名單匹配的頁面
作者 Victor Vasiliev (VasilievVVtalk)
最新版本 1.5.0 (Continuous updates)
兼容性方针 发行分支
MediaWiki 1.35+
PHP 7.0+
许可协议 GNU通用公眾授權條款2.0或更新版本
  • $wgTitleBlacklistSources
  • $wgTitleBlacklistUsernameSources
  • $wgTitleBlacklistCaching
  • $wgTitleBlacklistBlockAutoAccountCreation
  • $wgTitleBlacklistLogHits
  • tboverride
  • tboverride-account
  • titleblacklistlog
问题 开放的工作 · 报告错误



  • 下载文件,并将其放置在您extensions/文件夹中的TitleBlacklist目录内。
  • 将下列代码放置在您的LocalSettings.php的底部:
    wfLoadExtension( 'TitleBlacklist' );
  • 设置封鎖名單来源(见下文
  •   完成 – 在您的wiki上导航至Special:Version,以验证扩展已成功安装。
默认情况下,该扩展仅对非管理员用户有效。要使该扩展对所有用户有效,请设置$wgGroupPermissions['sysop']['tboverride'] = false;


應該採用 array( 名稱 => 來源描述 ) 的格式。 默认为空数组。
如果要將其限制為特定的來源,請使用 array( 來源名稱1, 來源名稱2 )。 This may be useful when you have shared account creation system in order to avoid blacklist fragmentation.
如果為true,則在Special:Log/titleblacklist上記錄所有與黑名單匹配的本地帳戶建立嘗試。 默认为false. 請注意即使禁用此選項,具有titleblacklistlog權限的使用者群組仍可見到該日誌。
也禁止與黑名單匹配的帳戶自動建立。 預設為true.



wfLoadExtension( 'TitleBlacklist' );
$wgTitleBlacklistSources = [
         'type' => 'localpage',
         'src'  => 'MediaWiki:Titleblacklist'
         'type' => 'url',
         'src'  => 'https://meta.wikimedia.org/w/index.php?title=Title_blacklist&action=raw'
         'type' => 'file',
         'src'  => '/home/wikipedia/blacklists/titles',






Foo <autoconfirmed|noedit|errmsg=blacklisted-testpage> #This page name is not allowed
[Bb]ar #No one should create article about it
.*pandora.* #This word is not allowed in any part of a page name


  • autoconfirmed - 允許自動確認使用者執行此類操作
  • casesensitive - 檢查標題是否被列入封鎖名單時不要忽略大小寫
  • noedit - 使用者也無法編輯這些頁面
  • moveonly - 禁止移動但允許普通建立 (rev:35163)
  • newaccountonly - 禁止建立匹配的使用者名稱,但允許建立頁面 (rev:38977)
  • reupload - 允許重新上傳現在被列入封鎖名單的檔案 (rev:33656)
  • errmsg - 應該顯示的訊息名稱,而不是標準名稱

如果已安裝AntiSpoof 擴充功能,您還能使用<antispoof>屬性。

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").


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



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

Custom messages can be defined by using the errmsg attribute.



The username for new accounts will be regarded by this extension differently to the way it regards new articles. This extension will prepend "User:" (or its localized equivalent) to the string that a user enters at Username on the create account page. So when this extension 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 block list regex "jill.* <newaccountonly>" and a user enters "jill" as the username on the create account page. This will pass as the comparison this extension 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.


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. 安装TitleBlacklist.

2. 将以下内容添加至您的LocalSettings.php

wfLoadExtension( 'TitleBlacklist' );
$wgGroupPermissions['sysop']['tboverride'] = false; 
$wgTitleBlacklistSources = [
    'type' => 'localpage',
    'src'  => 'MediaWiki:Titleblacklist'

3. 在https://www.example.com/mywiki/MediaWiki:Titleblacklist中添加

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

4. 在https://www.example.com/mywiki/MediaWiki:Titlewhitelist中添加

# 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 block list
User:[A-Z][a-z]+\s[A-Z][a-z]+ <casesensitive>

5. 在https://www.example.com/mywiki/MediaWiki:Titleblacklist-forbidden-new-account edit中编辑

The user name "$2" has been blocked from creation. It matches the following block list 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.

* "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 customized at MediaWiki:Titleblacklist-forbidden-new-account

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 block list. Users with the 'tboverride' right should be sure to supply the tbnooverride parameter.

For example, if the block list contained the filter:

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

you could use an API request like

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

For example, if the block list 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

Resources on regular expressions