(bug 30390) upload.js: Decode url encoding in file name.
authorkarun <karun.84@gmx.de>
Sat, 18 Aug 2012 23:28:40 +0000 (09:28 +1000)
committerTimo Tijhof <ttijhof@wikimedia.org>
Thu, 23 Aug 2012 16:56:21 +0000 (18:56 +0200)
Change-Id: I3a48f8a8033ff6a8cb0b1cb322c2af1fceccbf39

RELEASE-NOTES-1.20
skins/common/upload.js

index d6ff47f..c9bf279 100644 (file)
@@ -217,6 +217,8 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki.
 * (bug 39297) Show warning if thumbnail of animated image will not be animated.
 * (bug 38249) Parser will throw an exception instead of outputting gibberish if
   PCRE is compiled without support for unicode properties.
+* (bug 30390) Suggested file name on Special:Upload should not contain
+  illegal characters.
 
 === API changes in 1.20 ===
 * (bug 34316) Add ability to retrieve maximum upload size from MediaWiki API.
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 ) );