Merge "(bug 35727) mw.Api ajax() should put token parameter last."
authorKrinkle <ttijhof@wikimedia.org>
Tue, 19 Jun 2012 22:47:53 +0000 (22:47 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 19 Jun 2012 22:47:53 +0000 (22:47 +0000)
CREDITS
RELEASE-NOTES-1.20
resources/mediawiki.api/mediawiki.api.js

diff --git a/CREDITS b/CREDITS
index 89154a3..fd86da8 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -175,6 +175,7 @@ following names for their contribution to the product.
 * rgcjonas
 * Robert Treat
 * RockMFR
+* Russell Blau
 * Rusty Burchfield
 * Salvatore Ingala
 * Scott Colcord
index 5f13424..cf016b1 100644 (file)
@@ -121,6 +121,7 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki.
 * (bug 24985) Use $wgTmpDirectory as the default temp directory so that people
   who don't have access to /tmp can specify an alternative.
 * (bug 27283) SqlBagOStuff breaks PostgreSQL transactions
+* (bug 35727) mw.Api ajax() should put token parameter last.
 
 === API changes in 1.20 ===
 * (bug 34316) Add ability to retrieve maximum upload size from MediaWiki API.
index 225093b..74306d5 100644 (file)
                 * @return {jqXHR}
                 */
                ajax: function( parameters, ajaxOptions ) {
+                       var token;
                        parameters = $.extend( {}, this.defaults.parameters, parameters );
                        ajaxOptions = $.extend( {}, this.defaults.ajax, ajaxOptions );
 
+                       // Ensure that token parameter is last (per [[mw:API:Edit#Token]]).
+                       if ( parameters.token ) {
+                               token = parameters.token;
+                               delete parameters.token;
+                       }
                        // Some deployed MediaWiki >= 1.17 forbid periods in URLs, due to an IE XSS bug
                        // So let's escape them here. See bug #28235
                        // This works because jQuery accepts data as a query string or as an Object
                        ajaxOptions.data = $.param( parameters ).replace( /\./g, '%2E' );
-
+                       // If we extracted a token parameter, add it back in.
+                       if ( token ) {
+                               ajaxOptions.data += '&token=' + encodeURIComponent( token );
+                       }
                        ajaxOptions.error = function( xhr, textStatus, exception ) {
                                ajaxOptions.err( 'http', {
                                        xhr: xhr,