Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F5317
bug.16414.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
bzimport
Nov 21 2014, 10:25 PM
2014-11-21 22:25:41 (UTC+0)
Size
2 KB
Referenced Files
None
Subscribers
None
bug.16414.patch
View Options
### Eclipse Workspace Patch 1.0
#P mvw-exp
Index: includes/Skin.php
===================================================================
--- includes/Skin.php (revision 49448)
+++ includes/Skin.php (working copy)
@@ -343,6 +343,7 @@
global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
global $wgRestrictionTypes, $wgLivePreview;
global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
+
$ns = $wgTitle->getNamespace();
$nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ? $wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
@@ -386,9 +387,16 @@
'wgEnableAPI' => $wgEnableAPI,
'wgEnableWriteAPI' => $wgEnableWriteAPI,
'wgSeparatorTransformTable' => $compactSeparatorTransTable,
- 'wgDigitTransformTable' => $compactDigitTransTable,
+ 'wgDigitTransformTable' => $compactDigitTransTable,
);
+ //if on upload page output the extension list:
+ if( SpecialPage::resolveAlias( $wgTitle->getDBkey() ) == "Upload" ){
+ global $wgFileExtensions;
+ $vars['wgFileExtensions'] = $wgFileExtensions;
+ }
+
+
if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ){
$vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
$vars['wgDBname'] = $wgDBname;
Index: skins/common/upload.js
===================================================================
--- skins/common/upload.js (revision 49448)
+++ skins/common/upload.js (working copy)
@@ -118,6 +118,14 @@
if (!document.getElementById) {
return;
}
+
+ //remove any previously flagged errors
+ var e = document.getElementById('mw-upload-permitted');
+ if(e) e. className = '';
+
+ var e = document.getElementById('mw-upload-prohibited');
+ if(e) e.className = '';
+
var path = document.getElementById(id).value;
// Find trailing part
var slash = path.lastIndexOf('/');
@@ -130,7 +138,34 @@
} else {
fname = path.substring(backslash+1, 10000);
}
-
+ //check for the wgFileExtensions and clear if not a valid fname extension
+ if( wgFileExtensions ){
+ var found = false;
+ if( fname.lastIndexOf('.')!=-1 ){
+ var ext = fname.substr( fname.lastIndexOf('.')+1 );
+ for(var i=0; i < wgFileExtensions.length; i++){
+ if( wgFileExtensions[i] == ext )
+ found = true;
+ }
+ }
+ if(!found){
+ //clear the upload set mw-upload-permitted to error
+ document.getElementById(id).value = '';
+ var e = document.getElementById('mw-upload-permitted');
+ if(e) e. className = 'error';
+
+ var e = document.getElementById('mw-upload-prohibited');
+ if(e) e.className = 'error';
+
+ //clear the wpDestFile as well:
+ var e = document.getElementById('wpDestFile')
+ if(e) e.value = '';
+
+ //return false
+ return false;
+ }
+ }
+
// Capitalise first letter and replace spaces by underscores
fname = fname.charAt(0).toUpperCase().concat(fname.substring(1,10000)).replace(/ /g, '_');
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4878
Default Alt Text
bug.16414.patch (2 KB)
Attached To
Mode
T18414: Upload form should prevent submission of filename with disallowed extension
Attached
Detach File
Event Timeline
Log In to Comment