Rename four config variables to avoid 'blacklist' term
As part of our wider work on modernising and making more welcoming the language we use within and around MediaWiki, now is a good time for us to rename these configuration variables: - $wgFileBlacklist is now $wgProhibitedFileExtensions - $wgMimeTypeBlacklist is now $wgMimeTypeExclusions - $wgEnableUserEmailBlacklist is now $wgEnableUserEmailMuteList - $wgShortPagesNamespaceBlacklist is now $wgShortPagesNamespaceExclusions Bug: T277987 Depends-On: I91e065c58fda144a722a41cf532e717f962d7a64 Change-Id: I558a8b20d67d48edccce0d065aec2d22992e9dda
This commit is contained in:
parent
15071c7953
commit
4dae3b1a06
13 changed files with 65 additions and 32 deletions
|
|
@ -59,6 +59,13 @@ of automatic detection of possible phone numbers in a webpage in Safari on iOS.
|
|||
in jQuery 3. See T280944 for more information.
|
||||
* $wgMimeTypeBlacklist - This configuration array now prohibits the RFC 4329
|
||||
form of JavaScript, 'application/javascript', as well as previous MIME types.
|
||||
* A number of settings have been renamed. The former configuration variable
|
||||
names are deprecated, but will be used as the fall back if they are still set,
|
||||
and remain temporarily available for extensions which try to read them:
|
||||
- $wgFileBlacklist is now $wgProhibitedFileExtensions
|
||||
- $wgMimeTypeBlacklist is now $wgMimeTypeExclusions
|
||||
- $wgEnableUserEmailBlacklist is now $wgEnableUserEmailMuteList
|
||||
- $wgShortPagesNamespaceBlacklist is now $wgShortPagesNamespaceExclusions
|
||||
* …
|
||||
|
||||
==== Removed configuration ====
|
||||
|
|
|
|||
|
|
@ -1108,8 +1108,10 @@ $wgFileExtensions = [ 'png', 'gif', 'jpg', 'jpeg', 'webp' ];
|
|||
* Files with these extensions will never be allowed as uploads.
|
||||
* An array of file extensions to prevent being uploaded. You should
|
||||
* append to this array if you want to prevent additional file extensions.
|
||||
*
|
||||
* @since 1.37; previously $wgFileBlacklist
|
||||
*/
|
||||
$wgFileBlacklist = [
|
||||
$wgProhibitedFileExtensions = [
|
||||
# HTML may contain cookie-stealing JavaScript and web bugs
|
||||
'html', 'htm', 'js', 'jsb', 'mhtml', 'mht', 'xhtml', 'xht',
|
||||
# PHP scripts may execute arbitrary code on the server
|
||||
|
|
@ -1123,8 +1125,10 @@ $wgFileBlacklist = [
|
|||
/**
|
||||
* Files with these MIME types will never be allowed as uploads
|
||||
* if $wgVerifyMimeType is enabled.
|
||||
*
|
||||
* @since 1.37; previously $wgMimeTypeBlacklist
|
||||
*/
|
||||
$wgMimeTypeBlacklist = [
|
||||
$wgMimeTypeExclusions = [
|
||||
# HTML may contain cookie-stealing JavaScript and web bugs
|
||||
'text/html',
|
||||
# Similarly with JavaScript itself
|
||||
|
|
@ -1877,11 +1881,11 @@ $wgEnableUserEmail = true;
|
|||
$wgEnableSpecialMute = false;
|
||||
|
||||
/**
|
||||
* Set to true to enable user-to-user e-mail blacklist.
|
||||
* Set to true to enable user-to-user e-mail mutelist.
|
||||
*
|
||||
* @since 1.30
|
||||
* @since 1.37; previously $wgEnableUserEmailBlacklist
|
||||
*/
|
||||
$wgEnableUserEmailBlacklist = false;
|
||||
$wgEnableUserEmailMuteList = false;
|
||||
|
||||
/**
|
||||
* If true put the sending user's email in a Reply-To header
|
||||
|
|
@ -4714,12 +4718,12 @@ $wgNamespacesWithSubpages = [
|
|||
$wgContentNamespaces = [ NS_MAIN ];
|
||||
|
||||
/**
|
||||
* Optional array of namespaces which should be blacklisted from Special:ShortPages
|
||||
* Only pages inside $wgContentNamespaces but not $wgShortPagesNamespaceBlacklist will
|
||||
* Optional array of namespaces which should be excluded from Special:ShortPages.
|
||||
* Only pages inside $wgContentNamespaces but not $wgShortPagesNamespaceExclusions will
|
||||
* be shown on that page.
|
||||
* @since 1.30
|
||||
* @since 1.37; previously $wgShortPagesNamespaceBlacklist
|
||||
*/
|
||||
$wgShortPagesNamespaceBlacklist = [];
|
||||
$wgShortPagesNamespaceExclusions = [];
|
||||
|
||||
/**
|
||||
* Array of namespaces, in addition to the talk namespaces, where signatures
|
||||
|
|
|
|||
|
|
@ -255,8 +255,30 @@ if ( $wgMainWANCache === false ) {
|
|||
];
|
||||
}
|
||||
|
||||
// Blacklisted file extensions shouldn't appear on the "allowed" list
|
||||
$wgFileExtensions = array_values( array_diff( $wgFileExtensions, $wgFileBlacklist ) );
|
||||
// Back-compat
|
||||
if ( isset( $wgFileBlacklist ) ) {
|
||||
$wgProhibitedFileExtensions = array_merge( $wgProhibitedFileExtensions, $wgFileBlacklist );
|
||||
} else {
|
||||
$wgFileBlacklist = $wgProhibitedFileExtensions;
|
||||
}
|
||||
if ( isset( $wgMimeTypeBlacklist ) ) {
|
||||
$wgMimeTypeExclusions = array_merge( $wgMimeTypeExclusions, $wgMimeTypeBlacklist );
|
||||
} else {
|
||||
$wgMimeTypeBlacklist = $wgMimeTypeExclusions;
|
||||
}
|
||||
if ( isset( $wgEnableUserEmailBlacklist ) ) {
|
||||
$wgEnableUserEmailMuteList = $wgEnableUserEmailBlacklist;
|
||||
} else {
|
||||
$wgEnableUserEmailBlacklist = $wgEnableUserEmailMuteList;
|
||||
}
|
||||
if ( isset( $wgShortPagesNamespaceBlacklist ) ) {
|
||||
$wgShortPagesNamespaceExclusions = $wgShortPagesNamespaceBlacklist;
|
||||
} else {
|
||||
$wgShortPagesNamespaceBlacklist = $wgShortPagesNamespaceExclusions;
|
||||
}
|
||||
|
||||
// Prohibited file extensions shouldn't appear on the "allowed" list
|
||||
$wgFileExtensions = array_values( array_diff( $wgFileExtensions, $wgProhibitedFileExtensions ) );
|
||||
|
||||
// Fix path to icon images after they were moved in 1.24
|
||||
if ( $wgRightsIcon ) {
|
||||
|
|
|
|||
|
|
@ -102,10 +102,10 @@ class StreamFile {
|
|||
* have changed since.
|
||||
*/
|
||||
if ( $safe ) {
|
||||
global $wgFileBlacklist, $wgCheckFileExtensions, $wgStrictFileExtensions,
|
||||
$wgFileExtensions, $wgVerifyMimeType, $wgMimeTypeBlacklist;
|
||||
global $wgProhibitedFileExtensions, $wgCheckFileExtensions, $wgStrictFileExtensions,
|
||||
$wgFileExtensions, $wgVerifyMimeType, $wgMimeTypeExclusions;
|
||||
list( , $extList ) = UploadBase::splitExtensions( $filename );
|
||||
if ( UploadBase::checkFileExtensionList( $extList, $wgFileBlacklist ) ) {
|
||||
if ( UploadBase::checkFileExtensionList( $extList, $wgProhibitedFileExtensions ) ) {
|
||||
return 'unknown/unknown';
|
||||
}
|
||||
if ( $wgCheckFileExtensions && $wgStrictFileExtensions
|
||||
|
|
@ -113,7 +113,7 @@ class StreamFile {
|
|||
) {
|
||||
return 'unknown/unknown';
|
||||
}
|
||||
if ( $wgVerifyMimeType && in_array( strtolower( $type ), $wgMimeTypeBlacklist ) ) {
|
||||
if ( $wgVerifyMimeType && in_array( strtolower( $type ), $wgMimeTypeExclusions ) ) {
|
||||
return 'unknown/unknown';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ class DefaultPreferencesFactory implements PreferencesFactory {
|
|||
'EmailConfirmToEdit',
|
||||
'EnableEmail',
|
||||
'EnableUserEmail',
|
||||
'EnableUserEmailBlacklist',
|
||||
'EnableUserEmailMuteList',
|
||||
'EnotifMinorEdits',
|
||||
'EnotifRevealEditorAddress',
|
||||
'EnotifUserTalk',
|
||||
|
|
@ -785,7 +785,7 @@ class DefaultPreferencesFactory implements PreferencesFactory {
|
|||
'disabled' => $disableEmailPrefs,
|
||||
];
|
||||
|
||||
if ( $this->options->get( 'EnableUserEmailBlacklist' ) ) {
|
||||
if ( $this->options->get( 'EnableUserEmailMuteList' ) ) {
|
||||
$defaultPreferences['email-blacklist'] = [
|
||||
'type' => 'usersmultiselect',
|
||||
'label-message' => 'email-mutelist-label',
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ class SpecialMute extends FormSpecialPage {
|
|||
$config = $this->getConfig();
|
||||
$fields = [];
|
||||
if (
|
||||
$config->get( 'EnableUserEmailBlacklist' ) &&
|
||||
$config->get( 'EnableUserEmailMuteList' ) &&
|
||||
$config->get( 'EnableUserEmail' ) &&
|
||||
$this->getUser()->getEmailAuthenticationTimestamp()
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class SpecialShortPages extends QueryPage {
|
|||
$conds = [
|
||||
'page_namespace' => array_diff(
|
||||
$this->namespaceInfo->getContentNamespaces(),
|
||||
$config->get( 'ShortPagesNamespaceBlacklist' )
|
||||
$config->get( 'ShortPagesNamespaceExclusions' )
|
||||
),
|
||||
'page_is_redirect' => 0
|
||||
];
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ class UploadForm extends HTMLForm {
|
|||
"</div>\n";
|
||||
} else {
|
||||
# We have to list both preferred and prohibited
|
||||
$prohibitedExtensions = array_unique( $config->get( 'FileBlacklist' ) );
|
||||
$prohibitedExtensions = array_unique( $config->get( 'ProhibitedFileExtensions' ) );
|
||||
$extensionsList =
|
||||
'<div id="mw-upload-preferred">' .
|
||||
$this->msg( 'upload-preferred' )
|
||||
|
|
|
|||
|
|
@ -447,8 +447,8 @@ abstract class UploadBase {
|
|||
global $wgVerifyMimeType, $wgVerifyMimeTypeIE;
|
||||
if ( $wgVerifyMimeType ) {
|
||||
wfDebug( "mime: <$mime> extension: <{$this->mFinalExtension}>" );
|
||||
global $wgMimeTypeBlacklist;
|
||||
if ( $this->checkFileExtension( $mime, $wgMimeTypeBlacklist ) ) {
|
||||
global $wgMimeTypeExclusions;
|
||||
if ( self::checkFileExtension( $mime, $wgMimeTypeExclusions ) ) {
|
||||
return [ 'filetype-badmime', $mime ];
|
||||
}
|
||||
|
||||
|
|
@ -463,7 +463,7 @@ abstract class UploadBase {
|
|||
$extMime = $magic->getMimeTypeFromExtensionOrNull( (string)$this->mFinalExtension ) ?? '';
|
||||
$ieTypes = $magic->getIEMimeTypes( $this->mTempPath, $chunk, $extMime );
|
||||
foreach ( $ieTypes as $ieType ) {
|
||||
if ( $this->checkFileExtension( $ieType, $wgMimeTypeBlacklist ) ) {
|
||||
if ( self::checkFileExtension( $ieType, $wgMimeTypeExclusions ) ) {
|
||||
return [ 'filetype-bad-ie-mime', $ieType ];
|
||||
}
|
||||
}
|
||||
|
|
@ -1064,11 +1064,11 @@ abstract class UploadBase {
|
|||
}
|
||||
}
|
||||
|
||||
/* Don't allow users to override the blacklist (check file extension) */
|
||||
// Don't allow users to override the list of prohibited file extensions (check file extension)
|
||||
global $wgCheckFileExtensions, $wgStrictFileExtensions;
|
||||
global $wgFileExtensions, $wgFileBlacklist;
|
||||
global $wgFileExtensions, $wgProhibitedFileExtensions;
|
||||
|
||||
$blackListedExtensions = $this->checkFileExtensionList( $ext, $wgFileBlacklist );
|
||||
$blackListedExtensions = self::checkFileExtensionList( $ext, $wgProhibitedFileExtensions );
|
||||
|
||||
if ( $this->mFinalExtension == '' ) {
|
||||
$this->mTitleError = self::FILETYPE_MISSING;
|
||||
|
|
|
|||
|
|
@ -472,7 +472,7 @@ class UploadStash {
|
|||
* @return string
|
||||
*/
|
||||
public static function getExtensionForPath( $path ) {
|
||||
global $wgFileBlacklist;
|
||||
global $wgProhibitedFileExtensions;
|
||||
// Does this have an extension?
|
||||
$n = strrpos( $path, '.' );
|
||||
|
||||
|
|
@ -486,7 +486,7 @@ class UploadStash {
|
|||
}
|
||||
|
||||
$extension = File::normalizeExtension( $extension );
|
||||
if ( in_array( $extension, $wgFileBlacklist ) ) {
|
||||
if ( in_array( $extension, $wgProhibitedFileExtensions ) ) {
|
||||
// The file should already be checked for being evil.
|
||||
// However, if somehow we got here, we definitely
|
||||
// don't want to give it an extension of .php and
|
||||
|
|
|
|||
|
|
@ -1935,7 +1935,7 @@
|
|||
"uploadtext": "{{doc-important|<code>thumb</code> and <code>left</code> are magic words. Leave them untranslated!}}\nText displayed when uploading a file using [[Special:Upload]].",
|
||||
"upload-permitted": "Used in [[Special:Upload]]. Parameters:\n* $1 - list of file types, defined in the variable [[mw:Special:MyLanguage/Manual:$wgFileExtensions|$wgFileExtensions]]\n* $2 - count of items in $1 - for use in plural\nSee also:\n* {{msg-mw|Upload-preferred}}\n* {{msg-mw|Upload-prohibited}}",
|
||||
"upload-preferred": "Used in [[Special:Upload]]. Parameters:\n* $1 - list of file types, defined in the variable [[mw:Special:MyLanguage/Manual:$wgFileExtensions|$wgFileExtensions]]\n* $2 - count of items in $1 - for use in plural\nSee also:\n* {{msg-mw|Upload-permitted}}\n* {{msg-mw|Upload-prohibited}}",
|
||||
"upload-prohibited": "Used in [[Special:Upload]]. Parameters:\n* $1 - list of file types, defined in the variable [[mw:Special:MyLanguage/Manual:$wgFileBlacklist|$wgFileBlacklist]]\n* $2 - count of items in $1 - for use in plural\nSee also:\n* {{msg-mw|Upload-permitted}}\n* {{msg-mw|Upload-preferred}}",
|
||||
"upload-prohibited": "Used in [[Special:Upload]]. Parameters:\n* $1 - list of file types, defined in the variable [[mw:Special:MyLanguage/Manual:$wgProhibitedFileExtensions|$wgProhibitedFileExtensions]]\n* $2 - count of items in $1 - for use in plural\nSee also:\n* {{msg-mw|Upload-permitted}}\n* {{msg-mw|Upload-preferred}}",
|
||||
"uploadfooter": "{{notranslate}}",
|
||||
"upload-default-description": "{{ignored}}Custom default upload description. The contents of this message be will inserted in the field \"Summary\" on [[Special:Upload]].",
|
||||
"uploadlogpage": "{{doc-logpage}}\n\nPage title of [[Special:Log/upload]].",
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class SpecialMuteTest extends SpecialPageTestBase {
|
|||
|
||||
$this->userOptionsManager = $this->getServiceContainer()->getUserOptionsManager();
|
||||
$this->setMwGlobals( [
|
||||
'wgEnableUserEmailBlacklist' => true
|
||||
'wgEnableUserEmailMuteList' => true
|
||||
] );
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ class SpecialMuteTest extends SpecialPageTestBase {
|
|||
);
|
||||
|
||||
$this->setMwGlobals( [
|
||||
'wgEnableUserEmailBlacklist' => false
|
||||
'wgEnableUserEmailMuteList' => false
|
||||
] );
|
||||
|
||||
$user = $this->getTestUser()->getUser();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class SpecialShortPagesTest extends MediaWikiIntegrationTestCase {
|
|||
*/
|
||||
public function testGetQueryInfoRespectsContentNS( $contentNS, $blacklistNS, $expectedNS ) {
|
||||
$this->setMwGlobals( [
|
||||
'wgShortPagesNamespaceBlacklist' => $blacklistNS,
|
||||
'wgShortPagesNamespaceExclusions' => $blacklistNS,
|
||||
'wgContentNamespaces' => $contentNS
|
||||
] );
|
||||
$this->setTemporaryHook( 'ShortPagesQuery', static function () {
|
||||
|
|
|
|||
Loading…
Reference in a new issue