Extension:TitleBlacklist

From mediawiki.org
This page is a translated version of the page Extension:TitleBlacklist and the translation is 54% complete.
この拡張機能は MediaWiki 1.21 以降に同梱されています。 そのため再度ダウンロードする必要はありません。 しかし、提供されているその他の手順に従う必要はあります。
MediaWiki 拡張機能マニュアル
TitleBlacklist
リリースの状態: 安定
実装 利用者権限 , API
説明 正規表現ブラックリストにマッチしたページ名のページの作成を阻止します。
作者 Victor Vasiliev (VasilievVVトーク)
最新バージョン 1.5.0 (継続的な更新)
互換性の方針 MediaWiki とともにリリースされるスナップショット。 master には後方互換性がありません。
MediaWiki 1.35+
PHP 7.0+
ライセンス GNU 一般公衆利用許諾書 2.0 以降
ダウンロード
  • $wgTitleBlacklistSources
  • $wgTitleBlacklistUsernameSources
  • $wgTitleBlacklistCaching
  • $wgTitleBlacklistBlockAutoAccountCreation
  • $wgTitleBlacklistLogHits

  • tboverride
  • tboverride-account
  • titleblacklistlog
Quarterly downloads 49 (Ranked 100th)
translatewiki.net で翻訳を利用できる場合は、TitleBlacklist 拡張機能の翻訳にご協力ください
問題点 未解決のタスク · バグを報告
A proposal to rename this extension is discussed at タスク T254650.

TitleBlacklist拡張機能は、Wikiの管理者がRegular expressionに一致するタイトルのページの作成・移動・アップロードをブロックすること、およびRegular expressionに一致する利用者名を持つアカウントの作成をブロックすることを可能にします。

インストール

  • ダウンロードして、ファイルをextensions/フォルダー内のTitleBlacklistという名前のディレクトリ内に配置します。
    開発者とコード寄稿者は、上記の代わりに以下を使用してGitからインストールします:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/TitleBlacklist
  • 以下のコードを LocalSettings.php ファイルの末尾に追加します:
    wfLoadExtension( 'TitleBlacklist' );
    
  • ブロック リスト ソースを設定します(下記を参照)
  • Yes 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。
既定では管理者以外の利用者に影響します。既定ですべての利用者に適用するには $wgGroupPermissions['sysop']['tboverride'] = false; を使用します。

設定

$wgTitleBlacklistSources
タイトルブラックリストのソースの書き方。
配列形式( name => source description )でなければならない。 デフォルトでは空の配列がセットされています。
$wgTitleBlacklistUsernameSources
利用者名にかけるフィルターとして動作するソースの設定。
"*" is for all; false disables all.
特定のソースに限定したい場合、配列( source name 1, source name 2 )を書きます。 ブラックリストが断片化するのを防ぐために共有アカウントの作成システムを導入している場合に便利かもしれません。
$wgTitleBlacklistLogHits
trueだった場合、ブラックリストに一致するローカルのアカウント作成の操作のすべてをSpecial:Log/titleblacklistに記録します。 既定値はfalse.です。 Note that even disabled, the log will still be visible for users groups with the titleblacklistlog right.
$wgTitleBlacklistCaching
?
$wgTitleBlacklistBlockAutoAccountCreation
また、自動的にソフトウェア側で作成されたブラックリストに一致するアカウントもブロックされます。 既定値は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',
    ]
];

詳細は タスク T113864 を参照してください。

使用法

ブロックリスト

ページ名ブロック リストは MediaWiki:Titleblacklist のページにあります。

このページはそれぞれの個別の行ごとに正規表現で構成されます。 Each of them forbids the creation of pages whose titles match it. 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

それぞれのエントリは <> で囲まれ、| で分割された省略可能な属性を含むことができます。

  • autoconfirmed - 自動承認された利用者にのみ操作を許可します
  • casesensitive - ブラックリストに掲載されたタイトルを確認するときに大文字小文字の区別をする
  • noedit - also forbid editing the page (if it already exists)
  • moveonly - 作成はできますが、移動はできません (rev:35163)
  • newaccountonly - マッチする利用者名でアカウントを作成することはできませんが、ページの作成はできます (rev:38977)
  • reupload - ブラックリストに掲載されたファイルの再アップロードを許可 (rev:33656)
  • errmsg - 標準のものの代わりに表示されるメッセージの名前です

AntiSpoof 拡張機能がインストールされている場合、属性 ‎<antispoof> を使用することができます。

ここで「正規表現」として説明しているものは正式な正規表現ではなく、ハードコードされた正規表現パターンに挿入するためのサブパターンです。例えば、上記の例にある Foo/^Foo$/usi のような正規表現になります。

正規表現にアンダースコア (_) が含まれる場合、拡張機能により自動的にスペースに変換されます。これはタイトルの検査がテキスト形式("Page_title"ではなく、"Page title"の形)で行われるためです。

ホワイトリスト

MediaWiki:Titlewhitelist というホワイトリストもあります。順番としてはまずブラックリストが、続いてホワイトリストが適用されます。したがって、ブラックリストの正規表現に合致し、ホワイトリストの正規表現に合致しない入力はブロックされます。なお、ホワイトリストの使用にあたってLocalSettings.phpを変更する必要はありません。上記ブラックリスト向けの属性の一部(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 following system messages defined in the namespace Mediawiki:

カスタム メッセージは errmsg 属性を使用して定義できます。

例 : タイトルブラックリストを使用してアカウントの作成を制御する

概要

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.

使用法

アカウント作成時に、すべての利用者名をスペースで区切り、それぞれの名前を大文字にして必ず2つの名前で構成されるよう強制したい場合、次のようにしてください :

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.

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.

一致するかテスト

The API module action=titleblacklist can be used to test a title and action (e.g. edit, create, new-account) against the block list. 'tboverride' の権限がある利用者は、tbnooverride パラメーターの指定が必須になります。

ブロックリストにフィルターをかける 例 :

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

APIを使用することができます

結果
{
    "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 put on the block list]] 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, 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. 一致するエントリが見つかった場合、そのエントリの詳細情報が返ります。

ブロックリストにフィルターをかける 例 :

.*(.)\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")

マッチしたエントリの詳細が含まれる以下の表を返します :

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

Clearing the cache

The contents of the block lists are cached. Changes in block lists configured at a URL or a file on the server are not applied immediately. To force clearing the cache, edit and save the page MediaWiki:Titleblacklist (even if you don't change anything). It doesn't matter if it's configured as a block list or not. includes/Hooks.php を参照してください。

Resources on regular expressions

関連項目