* (bug 13342) importScript() generates more consistent URI encoding
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 3 Dec 2008 21:52:40 +0000 (21:52 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 3 Dec 2008 21:52:40 +0000 (21:52 +0000)
Switches order of URL to put title first, and encodes ':' and '/' consistently with MediaWiki general URI encoding.

The current implementation escapes ':' and '/', producing URLs like this:

/trunk/index.php?action=raw&ctype=text/javascript&title=MediaWiki%3ASysop.js

If we're recommending consistent use of importScript() it probably doesn't really matter, but it wouldn't hurt to be self-consistent with how we generate other URLs... of course even with the change to the encoding, the order of the pieces is different.

MediaWiki usually generates URLs with the title component first; also caching options will differ depending on who's generating the URL and when.

RELEASE-NOTES
skins/common/wikibits.js

index 3c1d546..6912fc5 100644 (file)
@@ -392,6 +392,7 @@ The following extensions are migrated into MediaWiki 1.14:
   pages if the repo wiki had a different canonical name for the File: namespace.
   Added 'fileNamespace' configuration item to $wgForeignFileRepos to override
   the local canonical name 'File' with another string.
+* (bug 13342) importScript() generates more consistent URI encoding
 
 
 === API changes in 1.14 ===
index 6611c05..3a1cea9 100644 (file)
@@ -48,7 +48,10 @@ function hookEvent(hookName, hookFunct) {
 }
 
 function importScript(page) {
-       return importScriptURI(wgScript + '?action=raw&ctype=text/javascript&title=' + encodeURIComponent(page.replace(/ /g,'_')));
+       var uri = wgScript + '?title=' +
+               encodeURIComponent(page.replace(/ /g,'_')).replace('%2F','/').replace('%3A',':') +
+               '&action=raw&ctype=text/javascript';
+       return importScriptURI(uri);
 }
  
 var loadedScripts = {}; // included-scripts tracker