Пашырэньне:Чорны сьпіс назваў

This page is a translated version of the page Extension:TitleBlacklist and the translation is 17% complete.
Outdated translations are marked like this.
Other languages:
Deutsch • ‎English • ‎Türkçe • ‎español • ‎français • ‎polski • ‎português do Brasil • ‎беларуская (тарашкевіца)‎ • ‎中文 • ‎日本語 • ‎한국어
This extension comes with MediaWiki 1.21 and above. Thus you do not have to download it again. However, you still need to follow the other instructions provided.
інструкцыя па пашырэньнях МэдыяВікі
OOjs UI icon advanced.svg
TitleBlacklist
Статус выданьня: стабільны
TitleBlacklist demonstration.png
Укараненьне Правы карыстальніка , API
Апісаньне Прадухіляе стварэньне старонак, якія адпавядаюць чорнаму сьпісу з рэгулярных выразаў
Аўтар(ы) Victor Vasiliev (VasilievVVгутаркі)
Апошняя вэрсія 1.5.0 (Continuous updates)
Палітыка сумяшчальнасьці галіны вэрсіяў
MediaWiki 1.35+
PHP 7.0+
Ліцэнзія Агульная публічная ліцэнзія GNU 2.0 ці навейшая
Загрузіць
  • $wgTitleBlacklistSources
  • $wgTitleBlacklistUsernameSources
  • $wgTitleBlacklistCaching
  • $wgTitleBlacklistBlockAutoAccountCreation
  • $wgTitleBlacklistLogHits
  • tboverride
  • tboverride-account
  • titleblacklistlog
Перакласьці пашырэньне TitleBlacklist, калі яно даступнае на translatewiki.net
Праверыць выкарыстаньне і матрыцу вэрсіяў.
Праблемы Адкрытыя задачы · Паведаміць пра памылку

Пашырэньне TitleBlacklist дазваляе вікі-адміністратарам прадухіляць стварэньне, перайменаваньне і загрузку старонак, назвы якіх супадаюць з адным ці некалькімі рэгулярнымі выразамі, а таксама прадухіляць стварэньне ўліковых запісаў з адпаведнымі імёнамі ўдзельнікаў.

Усталяваньне

  • Download and place the file(s) in a directory called TitleBlacklist in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    wfLoadExtension( 'TitleBlacklist' );
    
  • Наладзіць крыніцы чорнага сьпісу (глядзіце ніжэй)
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Дапомна ён датычыцца толькі карыстальнікаў-неапэратараў. Каб зрабіць яго дапомным для ўсіх, скарыстайце $wgGroupPermissions['sysop']['tboverride'] = false;.

Налады

$wgTitleBlacklistSources
Масіў крыніцаў чорнага сьпісу назваў.
Мусіць быць у фармаце масіў( назва => апісаньне крыніцы ). Defaults to an empty array.
$wgTitleBlacklistUsernameSources
Задае крыніцы, якія могуць быць фільтрам імёнаў карыстальнікаў.
'*' для ўсіх; false адключае ўсё.
Калі вы хочаце абмежаваць яго пэўнымі крыніцамі, скарыстайце масіў( назва крыніцы 1, назва крыніцы 2 ). Гэта можа быць карысным, калі вы маеце супольную сыстэму стварэньня ўліковых запісаў, і трэба пазьбегнуць падзяленьня чорнага сьпісу.
$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 block list sources

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

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',
    ]
];

See issue T113864 for further information.

Usage

Block list

The title block list 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> #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

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

  • autoconfirmed - also allows autoconfirmed users to perform such actions
  • casesensitive - do not ignore case when checking title for being put on the block list
  • noedit - users are also unable to edit these pages
  • 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 blocked files (rev:33656)
  • 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").

Safe list

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.

Customizing

Warning messages

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.

Example: Using TitleBlacklist to control user account creation

Conceptual overview

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.

How to

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

wfLoadExtension( 'TitleBlacklist' );
$wgGroupPermissions['sysop']['tboverride'] = false; 
$wgTitleBlacklistSources = [
  [
    'type' => '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 .* <newaccountonly> in block list
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 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.

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 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

See also