From 1d4ecc66b1d6827b6e39664f4f14fba50aa7907f Mon Sep 17 00:00:00 2001 From: karun Date: Sun, 19 Aug 2012 09:28:40 +1000 Subject: [PATCH] (bug 30390) upload.js: Decode url encoding in file name. Change-Id: I3a48f8a8033ff6a8cb0b1cb322c2af1fceccbf39 --- RELEASE-NOTES-1.20 | 2 ++ skins/common/upload.js | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index d6ff47f3ed..c9bf279df6 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -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. 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 ) ); -- 2.20.1