Update doc comments and code formatting.
[lhc/web/wiklou.git] / skins / common / upload.js
index 8e08af3..df819e1 100644 (file)
@@ -1,4 +1,4 @@
-( function () {
+( function ( mw, $ ) {
 var    ajaxUploadDestCheck = mw.config.get( 'wgAjaxUploadDestCheck' ),
        fileExtensions = mw.config.get( 'wgFileExtensions' );
 
@@ -241,10 +241,17 @@ window.fillDestFilename = function(id) {
        }
 
        // Output result
-       var destFile = document.getElementById('wpDestFile');
-       if (destFile) {
-               destFile.value = fname;
-               wgUploadWarningObj.checkNow(fname) ;
+       var destFile = document.getElementById( 'wpDestFile' );
+       if ( destFile ) {
+               // Call decodeURIComponent function to remove possible URL-encoded characters
+               // from the file name (bug 30390). Especially likely with upload-form-url.
+               // decodeURIComponent can throw an exception in input is invalid utf-8
+               try {
+                       destFile.value = decodeURIComponent( fname );
+               } catch ( e ) {
+                       destFile.value = fname;
+               }
+               wgUploadWarningObj.checkNow( fname );
        }
 };
 
@@ -302,4 +309,4 @@ window.wgUploadLicenseObj = {
 
 $( document ).ready( uploadSetup );
 
-}() );
+}( mediaWiki, jQuery ) );