X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22messagerie%22%29%20.%20%22?a=blobdiff_plain;f=skins%2Fcommon%2Fupload.js;h=df819e190dbc0f118c375bbd788bc43f470c19d1;hb=67bfdc7a68940d901e585eadd984a2074bf0216a;hp=8e08af31c55ec8ff0f23eab1edc6e3007bb259b3;hpb=425ae715aaf4facf1090ba716064a591992f59bf;p=lhc%2Fweb%2Fwiklou.git diff --git a/skins/common/upload.js b/skins/common/upload.js index 8e08af31c5..df819e190d 100644 --- a/skins/common/upload.js +++ b/skins/common/upload.js @@ -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 ) );