Manual:$wgMimeTypeExclusions/zh

From Linux Web Expert

<translate> MIME types</translate>: $wgMimeTypeExclusions
MIME types to disallow if $wgVerifyMimeType is enabled.
<translate> Introduced in version:</translate>1.37.0 (Gerrit change 680806; git #4dae3b1a)
<translate> Removed in version:</translate><translate> still in use</translate>
<translate> Allowed values:</translate>(MIME类型(字符串)的数组)
<translate> Default value:</translate>(参见下方)

细节

Files with these MIME types will never be allowed as uploads if $wgVerifyMimeType is enabled.

这个变量以前是$wgMimeTypeBlacklist

默认值

<td class="mw-version-versionbox" title="<translate nowrap> The latest stable version is <tvar name=1>1.41</tvar></translate>">
<translate> ≥</translate> 1.41
<translate> MediaWiki version:</translate>
$wgMimeTypeExclusions = [
	# HTML 可能含有窃取cookie的Javascript或web漏洞
	'text/html',
	# JavaScript也一样
	'application/javascript', 'text/javascript', 'text/x-javascript', 'application/x-shellscript',
	# PHP 脚本可能在服务器上执行任意代码
	'application/x-php', 'text/x-php',
	# Other types that may be interpreted by some servers
	'text/x-python', 'text/x-perl', 'text/x-bash', 'text/x-sh', 'text/x-csh',
	# Client-side hazards on Internet Explorer
	'text/scriptlet', 'application/x-msdownload',
	# Windows metafile, client-side vulnerability on some systems
	'application/x-msmetafile',
	# Files that look like java files
	'application/java',
	# XML files generally - T341565
	'application/xml', 'text/xml',
];
<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.40</tvar> is legacy version</translate>">
1.39 – 1.40
<translate> MediaWiki versions:</translate>
$wgMimeTypeExclusions = [
	# HTML may contain cookie-stealing JavaScript and web bugs
	'text/html',
	# Similarly with JavaScript itself
	'application/javascript', 'text/javascript', 'text/x-javascript', 'application/x-shellscript',
	# PHP scripts may execute arbitrary code on the server
	'application/x-php', 'text/x-php',
	# Other types that may be interpreted by some servers
	'text/x-python', 'text/x-perl', 'text/x-bash', 'text/x-sh', 'text/x-csh',
	# Client-side hazards on Internet Explorer
	'text/scriptlet', 'application/x-msdownload',
	# Windows metafile, client-side vulnerability on some systems
	'application/x-msmetafile',
	# Java applets are no longer supported by browsers and may contain cookie-stealing code, similarly to JavaScript
	'application/java'
];
<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.38</tvar> is unsupported version</translate>">
1.37 – 1.38
<translate> MediaWiki versions:</translate>
$wgMimeTypeExclusions = [
	# HTML may contain cookie-stealing JavaScript and web bugs
	'text/html',
	# Similarly with JavaScript itself
	'application/javascript', 'text/javascript', 'text/x-javascript', 'application/x-shellscript',
	# PHP scripts may execute arbitrary code on the server
	'application/x-php', 'text/x-php',
	# Other types that may be interpreted by some servers
	'text/x-python', 'text/x-perl', 'text/x-bash', 'text/x-sh', 'text/x-csh',
	# Client-side hazards on Internet Explorer
	'text/scriptlet', 'application/x-msdownload',
	# Windows metafile, client-side vulnerability on some systems
	'application/x-msmetafile',
];

-{zh-hans:示例; zh-hant:範例;}-

如果你想允许上传HTML文件:

$wgFileExtensions[] = 'html';
$wgProhibitedFileExtensions = array_diff( $wgProhibitedFileExtensions, array ('html') );
$wgMimeTypeExclusions = array_diff( $wgMimeTypeExclusions, array ('text/html') );