Merge "Fix incorrect @covers tags in LinksUpdateTest"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 27 Feb 2014 19:17:06 +0000 (19:17 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 27 Feb 2014 19:17:06 +0000 (19:17 +0000)
.jshintignore
includes/DefaultSettings.php
includes/GlobalFunctions.php
includes/User.php
includes/api/ApiFormatBase.php
includes/resourceloader/ResourceLoaderStartUpModule.php
includes/upload/UploadBase.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messageTypes.inc
tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js

index 0e3c679..a44a4d4 100644 (file)
@@ -16,6 +16,7 @@ resources/jquery/jquery.cookie.js
 resources/jquery/jquery.cycle.all.js
 resources/jquery/jquery.farbtastic.js
 resources/jquery/jquery.form.js
+resources/jquery/jquery.fullscreen.js
 resources/jquery/jquery.hoverIntent.js
 resources/jquery/jquery.js
 resources/jquery/jquery.json.js
index 716baef..b9b471c 100644 (file)
@@ -4951,10 +4951,12 @@ $wgDebugDumpSql = false;
  * of the regular $wgDebugLogFile. Useful for enabling selective logging
  * in production.
  *
- * Log destinations may be string values specifying a filename or URI, or they
- * may be filename or an associative array mapping 'destination' to the desired
- * filename. The associative array may also contain a 'sample' key with an
- * integer value, specifying a sampling factor.
+ * Log destinations may be one of the following:
+ * - false to completely remove from the output, including from $wgDebugLogFile.
+ * - string values specifying a filename or URI.
+ * - associative array mapping 'destination' key to the desired filename or URI.
+ *   The associative array may also contain a 'sample' key with an integer value,
+ *   specifying a sampling factor.
  *
  * @par Example:
  * @code
index 6785d0c..a6f936f 100644 (file)
@@ -1064,6 +1064,9 @@ function wfDebugLog( $logGroup, $text, $dest = 'all' ) {
        }
 
        $logConfig = $wgDebugLogGroups[$logGroup];
+       if ( $logConfig === false ) {
+               return;
+       }
        if ( is_array( $logConfig ) ) {
                if ( isset( $logConfig['sample'] ) && mt_rand( 1, $logConfig['sample'] ) !== 1 ) {
                        return;
index 4b57dd2..0b28f66 100644 (file)
@@ -1056,7 +1056,8 @@ class User {
                        # Get the token from DB/cache and clean it up to remove garbage padding.
                        # This deals with historical problems with bugs and the default column value.
                        $token = rtrim( $proposedUser->getToken( false ) ); // correct token
-                       $passwordCorrect = ( strlen( $token ) && $token === $request->getCookie( 'Token' ) );
+                       // Make comparison in constant time (bug 61346)
+                       $passwordCorrect = strlen( $token ) && $this->compareSecrets( $token, $request->getCookie( 'Token' ) );
                        $from = 'cookie';
                } else {
                        // No session or persistent login cookie
@@ -1075,6 +1076,25 @@ class User {
                }
        }
 
+       /**
+        * A comparison of two strings, not vulnerable to timing attacks
+        * @param string $answer the secret string that you are comparing against.
+        * @param string $test compare this string to the $answer.
+        * @return bool True if the strings are the same, false otherwise
+        */
+       protected function compareSecrets( $answer, $test ) {
+               if ( strlen( $answer ) !== strlen( $test ) ) {
+                       $passwordCorrect = false;
+               } else {
+                       $result = 0;
+                       for ( $i = 0; $i < strlen( $answer ); $i++ ) {
+                               $result |= ord( $answer{$i} ) ^ ord( $test{$i} );
+                       }
+                       $passwordCorrect = ( $result == 0 );
+               }
+               return $passwordCorrect;
+       }
+
        /**
         * Load user and user_group data from the database.
         * $this->mId must be set, this is how the user is identified.
index 63a5502..49a02fe 100644 (file)
@@ -271,12 +271,22 @@ See the <a href='https://www.mediawiki.org/wiki/API'>complete documentation</a>,
                // encode all comments or tags as safe blue strings
                $text = str_replace( '&lt;', '<span style="color:blue;">&lt;', $text );
                $text = str_replace( '&gt;', '&gt;</span>', $text );
+
                // identify requests to api.php
-               $text = preg_replace( "#api\\.php\\?[^ <\n\t]+#", '<a href="\\0">\\0</a>', $text );
+               $text = preg_replace( '#^(\s*)(api\.php\?[^ <\n\t]+)$#m', '\1<a href="\2">\2</a>', $text );
                if ( $this->mHelp ) {
                        // make strings inside * bold
                        $text = preg_replace( "#\\*[^<>\n]+\\*#", '<b>\\0</b>', $text );
                }
+
+               // Armor links (bug 61362)
+               $masked = array();
+               $text = preg_replace_callback( '#<a .*?</a>#', function ( $matches ) use ( &$masked ) {
+                       $sha = sha1( $matches[0] );
+                       $masked[$sha] = $matches[0];
+                       return "<$sha>";
+               }, $text );
+
                // identify URLs
                $protos = wfUrlProtocolsWithoutProtRel();
                // This regex hacks around bug 13218 (&quot; included in the URL)
@@ -286,6 +296,12 @@ See the <a href='https://www.mediawiki.org/wiki/API'>complete documentation</a>,
                        $text
                );
 
+               // Unarmor links
+               $text = preg_replace_callback( '#<([0-9a-f]{40})>#', function ( $matches ) use ( &$masked ) {
+                       $sha = $matches[1];
+                       return isset( $masked[$sha] ) ? $masked[$sha] : $matches[0];
+               }, $text );
+
                /**
                 * Temporary fix for bad links in help messages. As a special case,
                 * XML-escaped metachars are de-escaped one level in the help message
index d0c3068..207e96b 100644 (file)
@@ -185,6 +185,43 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                return true;
        }
 
+       /**
+        * Get the load URL of the startup modules.
+        *
+        * This is a helper for getScript(), but can also be called standalone, such
+        * as when generating an AppCache manifest.
+        *
+        * @param $context ResourceLoaderContext
+        * @return string
+        */
+       public static function getStartupModulesUrl( ResourceLoaderContext $context ) {
+               // The core modules:
+               $moduleNames = array( 'jquery', 'mediawiki' );
+               wfRunHooks( 'ResourceLoaderGetStartupModules', array( &$moduleNames ) );
+
+               // Get the latest version
+               $loader = $context->getResourceLoader();
+               $version = 0;
+               foreach ( $moduleNames as $moduleName ) {
+                       $version = max( $version,
+                               $loader->getModule( $moduleName )->getModifiedTime( $context )
+                       );
+               }
+
+               $query = array(
+                       'modules' => ResourceLoader::makePackedModulesString( $moduleNames ),
+                       'only' => 'scripts',
+                       'lang' => $context->getLanguage(),
+                       'skin' => $context->getSkin(),
+                       'debug' => $context->getDebug() ? 'true' : 'false',
+                       'version' => wfTimestamp( TS_ISO_8601_BASIC, $version )
+               );
+               // Ensure uniform query order
+               ksort( $query );
+               return  wfAppendQuery( wfScript( 'load' ), $query );
+       }
+
+
        /**
         * @param $context ResourceLoaderContext
         * @return string
@@ -195,30 +232,6 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                $out = file_get_contents( "$IP/resources/startup.js" );
                if ( $context->getOnly() === 'scripts' ) {
 
-                       // The core modules:
-                       $moduleNames = array( 'jquery', 'mediawiki' );
-                       wfRunHooks( 'ResourceLoaderGetStartupModules', array( &$moduleNames ) );
-
-                       // Get the latest version
-                       $loader = $context->getResourceLoader();
-                       $version = 0;
-                       foreach ( $moduleNames as $moduleName ) {
-                               $version = max( $version,
-                                       $loader->getModule( $moduleName )->getModifiedTime( $context )
-                               );
-                       }
-                       // Build load query for StartupModules
-                       $query = array(
-                               'modules' => ResourceLoader::makePackedModulesString( $moduleNames ),
-                               'only' => 'scripts',
-                               'lang' => $context->getLanguage(),
-                               'skin' => $context->getSkin(),
-                               'debug' => $context->getDebug() ? 'true' : 'false',
-                               'version' => wfTimestamp( TS_ISO_8601_BASIC, $version )
-                       );
-                       // Ensure uniform query order
-                       ksort( $query );
-
                        // Startup function
                        $configuration = $this->getConfig( $context );
                        $registrations = self::getModuleRegistrations( $context );
@@ -230,7 +243,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                                "};\n";
 
                        // Conditional script injection
-                       $scriptTag = Html::linkedScript( wfAppendQuery( wfScript( 'load' ), $query ) );
+                       $scriptTag = Html::linkedScript( self::getStartupModulesUrl( $context ) );
                        $out .= "if ( isCompatible() ) {\n" .
                                "\t" . Xml::encodeJsCall( 'document.write', array( $scriptTag ) ) .
                                "}\n" .
index 67bffc3..db7a24e 100644 (file)
@@ -42,7 +42,7 @@ abstract class UploadBase {
        protected $mFilteredName, $mFinalExtension;
        protected $mLocalFile, $mFileSize, $mFileProps;
        protected $mBlackListedExtensions;
-       protected $mJavaDetected;
+       protected $mJavaDetected, $mSVGNSError;
 
        protected static $safeXmlEncodings = array( 'UTF-8', 'ISO-8859-1', 'ISO-8859-2', 'UTF-16', 'UTF-32' );
 
@@ -1168,6 +1168,7 @@ abstract class UploadBase {
         * @return mixed false of the file is verified (does not contain scripts), array otherwise.
         */
        protected function detectScriptInSvg( $filename ) {
+               $this->mSVGNSError = false;
                $check = new XmlTypeCheck(
                        $filename,
                        array( $this, 'checkSvgScriptCallback' ),
@@ -1178,6 +1179,9 @@ abstract class UploadBase {
                        // Invalid xml (bug 58553)
                        return array( 'uploadinvalidxml' );
                } elseif ( $check->filterMatch ) {
+                       if ( $this->mSVGNSError ) {
+                               return array( 'uploadscriptednamespace', $this->mSVGNSError );
+                       }
                        return array( 'uploadscripted' );
                }
                return false;
@@ -1204,7 +1208,51 @@ abstract class UploadBase {
         * @return bool
         */
        public function checkSvgScriptCallback( $element, $attribs ) {
-               $strippedElement = $this->stripXmlNamespace( $element );
+               list( $namespace, $strippedElement ) = $this->splitXmlNamespace( $element );
+
+               static $validNamespaces = array(
+                       '',
+                       'adobe:ns:meta/',
+                       'http://creativecommons.org/ns#',
+                       'http://inkscape.sourceforge.net/dtd/sodipodi-0.dtd',
+                       'http://ns.adobe.com/adobeillustrator/10.0/',
+                       'http://ns.adobe.com/adobesvgviewerextensions/3.0/',
+                       'http://ns.adobe.com/extensibility/1.0/',
+                       'http://ns.adobe.com/flows/1.0/',
+                       'http://ns.adobe.com/illustrator/1.0/',
+                       'http://ns.adobe.com/imagereplacement/1.0/',
+                       'http://ns.adobe.com/pdf/1.3/',
+                       'http://ns.adobe.com/photoshop/1.0/',
+                       'http://ns.adobe.com/saveforweb/1.0/',
+                       'http://ns.adobe.com/variables/1.0/',
+                       'http://ns.adobe.com/xap/1.0/',
+                       'http://ns.adobe.com/xap/1.0/g/',
+                       'http://ns.adobe.com/xap/1.0/g/img/',
+                       'http://ns.adobe.com/xap/1.0/mm/',
+                       'http://ns.adobe.com/xap/1.0/rights/',
+                       'http://ns.adobe.com/xap/1.0/stype/dimensions#',
+                       'http://ns.adobe.com/xap/1.0/stype/font#',
+                       'http://ns.adobe.com/xap/1.0/stype/manifestitem#',
+                       'http://ns.adobe.com/xap/1.0/stype/resourceevent#',
+                       'http://ns.adobe.com/xap/1.0/stype/resourceref#',
+                       'http://ns.adobe.com/xap/1.0/t/pg/',
+                       'http://purl.org/dc/elements/1.1/',
+                       'http://purl.org/dc/elements/1.1',
+                       'http://schemas.microsoft.com/visio/2003/svgextensions/',
+                       'http://sodipodi.sourceforge.net/dtd/sodipodi-0.dtd',
+                       'http://web.resource.org/cc/',
+                       'http://www.freesoftware.fsf.org/bkchem/cdml',
+                       'http://www.inkscape.org/namespaces/inkscape',
+                       'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
+                       'http://www.w3.org/2000/svg',
+               );
+
+               if ( !in_array( $namespace, $validNamespaces ) ) {
+                       wfDebug( __METHOD__ . ": Non-svg namespace '$namespace' in uploaded file.\n" );
+                       // @TODO return a status object to a closure in XmlTypeCheck, for MW1.21+
+                       $this->mSVGNSError = $namespace;
+                       return true;
+               }
 
                /*
                 * check for elements that can contain javascript
@@ -1226,6 +1274,13 @@ abstract class UploadBase {
                        return true;
                }
 
+               # Block iframes, in case they pass the namespace check
+               if ( $strippedElement == 'iframe' ) {
+                       wfDebug( __METHOD__ . ": iframe in uploaded file.\n" );
+                       return true;
+               }
+
+
                foreach ( $attribs as $attrib => $value ) {
                        $stripped = $this->stripXmlNamespace( $attrib );
                        $value = strtolower( $value );
@@ -1299,6 +1354,19 @@ abstract class UploadBase {
                return false; //No scripts detected
        }
 
+       /**
+        * Divide the element name passed by the xml parser to the callback into URI and prifix.
+        * @param $name string
+        * @return array containing the namespace URI and prefix
+        */
+       private static function splitXmlNamespace( $element ) {
+               // 'http://www.w3.org/2000/svg:script' -> array( 'http://www.w3.org/2000/svg', 'script' )
+               $parts = explode( ':', strtolower( $element ) );
+               $name = array_pop( $parts );
+               $ns = implode( ':', $parts );
+               return array( $ns, $name );
+       }
+
        /**
         * @param $name string
         * @return string
index 966c6a9..aecd24e 100644 (file)
@@ -2366,6 +2366,7 @@ You should ask someone with the ability to view suppressed file data to review t
 'php-uploaddisabledtext'         => 'File uploads are disabled in PHP.
 Please check the file_uploads setting.',
 'uploadscripted'                 => 'This file contains HTML or script code that may be erroneously interpreted by a web browser.',
+'uploadscriptednamespace'     => 'This SVG file contains an illegal namespace \'$1\'',
 'uploadinvalidxml'               => 'The XML in the uploaded file could not be parsed.',
 'uploadvirus'                    => 'The file contains a virus!
 Details: $1',
@@ -4660,7 +4661,7 @@ Please confirm that you really want to recreate this page.',
 'percent'             => '$1%', # only translate this message to other languages if you have to change it
 'parentheses'         => '($1)', # only translate this message to other languages if you have to change it
 'brackets'            => '[$1]', # only translate this message to other languages if you have to change it
-'quotation-marks'     => '"$1"', # only translate this message to other languages if you have to change it
+'quotation-marks'     => '"$1"',
 
 # Multipage image navigation
 'imgmultipageprev' => '← previous page',
index fb563fb..3a66c42 100644 (file)
@@ -4210,6 +4210,14 @@ See also:
 'php-uploaddisabledtext' => 'This means that file uploading is disabled in PHP, not upload of PHP-files.',
 'uploadscripted' => 'Used as error message when uploading a file.
 
+See also:
+* {{msg-mw|zip-wrong-format}}
+* {{msg-mw|uploadjava}}
+* {{msg-mw|uploadvirus}}',
+'uploadscriptednamespace' => 'Used as error message when uploading a file. This error is specific to SVG files, when they include a namespace that has not been whitelisted.
+
+Parameters:
+* $1 - the invalid namespace name
 See also:
 * {{msg-mw|zip-wrong-format}}
 * {{msg-mw|uploadjava}}
index 46b0362..142727c 100644 (file)
@@ -498,7 +498,6 @@ $wgOptionalMessages = array(
        'limitreport-expensivefunctioncount-value',
        'interlanguage-link-title',
        'img-lang-opt',
-       'quotation-marks',
        'recentchanges-legend-plusminus',
 );
 
index f73fd7b..fe174ce 100644 (file)
@@ -1,7 +1,161 @@
 ( function ( $, mw ) {
-       /*jshint onevar: false */
+       var config, header,
 
-       var config = {
+               // Data set "simple"
+               a1 = [ 'A', '1' ],
+               a2 = [ 'A', '2' ],
+               a3 = [ 'A', '3' ],
+               b1 = [ 'B', '1' ],
+               b2 = [ 'B', '2' ],
+               b3 = [ 'B', '3' ],
+               simple = [a2, b3, a1, a3, b2, b1],
+               simpleAsc = [a1, a2, a3, b1, b2, b3],
+               simpleDescasc = [b1, b2, b3, a1, a2, a3],
+
+               // Data set "colspan"
+               aaa1 = [ 'A', 'A', 'A', '1' ],
+               aab5 = [ 'A', 'A', 'B', '5' ],
+               abc3 = [ 'A', 'B', 'C', '3' ],
+               bbc2 = [ 'B', 'B', 'C', '2' ],
+               caa4 = [ 'C', 'A', 'A', '4' ],
+               colspanInitial = [ aab5, aaa1, abc3, bbc2, caa4 ],
+
+               // Data set "planets"
+               mercury = [ 'Mercury', '2439.7' ],
+               venus = [ 'Venus', '6051.8' ],
+               earth = [ 'Earth', '6371.0' ],
+               mars = [ 'Mars', '3390.0' ],
+               jupiter = [ 'Jupiter', '69911' ],
+               saturn = [ 'Saturn', '58232' ],
+               planets = [mercury, venus, earth, mars, jupiter, saturn],
+               planetsAscName = [earth, jupiter, mars, mercury, saturn, venus],
+               planetsAscRadius = [mercury, mars, venus, earth, saturn, jupiter],
+               planetsRowspan,
+               planetsRowspanII,
+               planetsAscNameLegacy,
+
+               // Data set "ipv4"
+               ipv4 = [
+                       // Some randomly generated fake IPs
+                       ['45.238.27.109'],
+                       ['44.172.9.22'],
+                       ['247.240.82.209'],
+                       ['204.204.132.158'],
+                       ['170.38.91.162'],
+                       ['197.219.164.9'],
+                       ['45.68.154.72'],
+                       ['182.195.149.80']
+               ],
+               ipv4Sorted = [
+                       // Sort order should go octet by octet
+                       ['44.172.9.22'],
+                       ['45.68.154.72'],
+                       ['45.238.27.109'],
+                       ['170.38.91.162'],
+                       ['182.195.149.80'],
+                       ['197.219.164.9'],
+                       ['204.204.132.158'],
+                       ['247.240.82.209']
+               ],
+
+               // Data set "umlaut"
+               umlautWords = [
+                       ['Günther'],
+                       ['Peter'],
+                       ['Björn'],
+                       ['Bjorn'],
+                       ['Apfel'],
+                       ['Äpfel'],
+                       ['Strasse'],
+                       ['Sträßschen']
+               ],
+               umlautWordsSorted = [
+                       ['Äpfel'],
+                       ['Apfel'],
+                       ['Björn'],
+                       ['Bjorn'],
+                       ['Günther'],
+                       ['Peter'],
+                       ['Sträßschen'],
+                       ['Strasse']
+               ],
+
+               complexMDYDates = [
+                       ['January, 19 2010'],
+                       ['April 21 1991'],
+                       ['04 22 1991'],
+                       ['5.12.1990'],
+                       ['December 12 \'10']
+               ],
+               complexMDYSorted = [
+                       ['5.12.1990'],
+                       ['April 21 1991'],
+                       ['04 22 1991'],
+                       ['January, 19 2010'],
+                       ['December 12 \'10']
+               ],
+
+               currencyUnsorted = [
+                       ['1.02 $'],
+                       ['$ 3.00'],
+                       ['€ 2,99'],
+                       ['$ 1.00'],
+                       ['$3.50'],
+                       ['$ 1.50'],
+                       ['€ 0.99']
+               ],
+               currencySorted = [
+                       ['€ 0.99'],
+                       ['$ 1.00'],
+                       ['1.02 $'],
+                       ['$ 1.50'],
+                       ['$ 3.00'],
+                       ['$3.50'],
+                       // Comma's sort after dots
+                       // Not intentional but test to detect changes
+                       ['€ 2,99']
+               ],
+
+               numbers = [
+                       [ '12'    ],
+                       [  '7'    ],
+                       [ '13,000'],
+                       [  '9'    ],
+                       [ '14'    ],
+                       [  '8.0'  ]
+               ],
+               numbersAsc = [
+                       [  '7'    ],
+                       [  '8.0'  ],
+                       [  '9'    ],
+                       [ '12'    ],
+                       [ '14'    ],
+                       [ '13,000']
+               ],
+
+               correctDateSorting1 = [
+                       ['01 January 2010'],
+                       ['05 February 2010'],
+                       ['16 January 2010']
+               ],
+               correctDateSortingSorted1 = [
+                       ['01 January 2010'],
+                       ['16 January 2010'],
+                       ['05 February 2010']
+               ],
+
+               correctDateSorting2 = [
+                       ['January 01 2010'],
+                       ['February 05 2010'],
+                       ['January 16 2010']
+               ],
+               correctDateSortingSorted2 = [
+                       ['January 01 2010'],
+                       ['January 16 2010'],
+                       ['February 05 2010']
+               ];
+
+       config = {
                wgMonthNames: ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
                wgMonthNamesShort: ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
                wgDefaultDateFormat: 'dmy',
         */
        function tableTest( msg, header, data, expected, callback ) {
                QUnit.test( msg, 1, function ( assert ) {
-                       var $table = tableCreate( header, data );
+                       var extracted,
+                               $table = tableCreate( header, data );
 
                        // Give caller a chance to set up sorting and manipulate the table.
                        callback( $table );
 
                        // Table sorting is done synchronously; if it ever needs to change back
                        // to asynchronous, we'll need a timeout or a callback here.
-                       var extracted = tableExtract( $table );
+                       extracted = tableExtract( $table );
                        assert.deepEqual( extracted, expected, msg );
                } );
        }
         */
        function tableTestHTML( msg, html, expected, callback ) {
                QUnit.test( msg, 1, function ( assert ) {
-                       var $table = $( html );
+                       var extracted,
+                               $table = $( html );
 
                        // Give caller a chance to set up sorting and manipulate the table.
                        if ( callback ) {
 
                        // Table sorting is done synchronously; if it ever needs to change back
                        // to asynchronous, we'll need a timeout or a callback here.
-                       var extracted = tableExtract( $table );
+                       extracted = tableExtract( $table );
                        assert.deepEqual( extracted, expected, msg );
                } );
        }
        }
 
        // Sample data set using planets named and their radius
-       var header = [ 'Planet' , 'Radius (km)'],
-               mercury = [ 'Mercury', '2439.7' ],
-               venus = [ 'Venus'  , '6051.8' ],
-               earth = [ 'Earth'  , '6371.0' ],
-               mars = [ 'Mars'   , '3390.0' ],
-               jupiter = [ 'Jupiter', '69911' ],
-               saturn = [ 'Saturn' , '58232' ];
-
-       // Initial data set
-       var planets = [mercury, venus, earth, mars, jupiter, saturn];
-       var ascendingName = [earth, jupiter, mars, mercury, saturn, venus];
-       var ascendingRadius = [mercury, mars, venus, earth, saturn, jupiter];
+       header = [ 'Planet', 'Radius (km)'];
 
        tableTest(
                'Basic planet table: sorting initially - ascending by name',
                header,
                planets,
-               ascendingName,
+               planetsAscName,
                function ( $table ) {
                        $table.tablesorter( { sortList: [
                                { 0: 'asc' }
                'Basic planet table: sorting initially - descending by radius',
                header,
                planets,
-               reversed( ascendingRadius ),
+               reversed( planetsAscRadius ),
                function ( $table ) {
                        $table.tablesorter( { sortList: [
                                { 1: 'desc' }
                'Basic planet table: ascending by name',
                header,
                planets,
-               ascendingName,
+               planetsAscName,
                function ( $table ) {
                        $table.tablesorter();
                        $table.find( '.headerSort:eq(0)' ).click();
                'Basic planet table: ascending by name a second time',
                header,
                planets,
-               ascendingName,
+               planetsAscName,
                function ( $table ) {
                        $table.tablesorter();
                        $table.find( '.headerSort:eq(0)' ).click();
                'Basic planet table: ascending by name (multiple clicks)',
                header,
                planets,
-               ascendingName,
+               planetsAscName,
                function ( $table ) {
                        $table.tablesorter();
                        $table.find( '.headerSort:eq(0)' ).click();
                'Basic planet table: descending by name',
                header,
                planets,
-               reversed( ascendingName ),
+               reversed( planetsAscName ),
                function ( $table ) {
                        $table.tablesorter();
                        $table.find( '.headerSort:eq(0)' ).click().click();
                'Basic planet table: ascending radius',
                header,
                planets,
-               ascendingRadius,
+               planetsAscRadius,
                function ( $table ) {
                        $table.tablesorter();
                        $table.find( '.headerSort:eq(1)' ).click();
                'Basic planet table: descending radius',
                header,
                planets,
-               reversed( ascendingRadius ),
+               reversed( planetsAscRadius ),
                function ( $table ) {
                        $table.tablesorter();
                        $table.find( '.headerSort:eq(1)' ).click().click();
                }
        );
 
-       // Sample data set to test multiple column sorting
-       header = [ 'column1' , 'column2'];
-       var
-               a1 = [ 'A', '1' ],
-               a2 = [ 'A', '2' ],
-               a3 = [ 'A', '3' ],
-               b1 = [ 'B', '1' ],
-               b2 = [ 'B', '2' ],
-               b3 = [ 'B', '3' ];
-       var initial = [a2, b3, a1, a3, b2, b1];
-       var asc = [a1, a2, a3, b1, b2, b3];
-       var descasc = [b1, b2, b3, a1, a2, a3];
+       header = [ 'column1', 'column2' ];
 
        tableTest(
                'Sorting multiple columns by passing sort list',
                header,
-               initial,
-               asc,
+               simple,
+               simpleAsc,
                function ( $table ) {
                        $table.tablesorter(
                                { sortList: [
        tableTest(
                'Sorting multiple columns by programmatically triggering sort()',
                header,
-               initial,
-               descasc,
+               simple,
+               simpleDescasc,
                function ( $table ) {
                        $table.tablesorter();
                        $table.data( 'tablesorter' ).sort(
        tableTest(
                'Reset to initial sorting by triggering sort() without any parameters',
                header,
-               initial,
-               asc,
+               simple,
+               simpleAsc,
                function ( $table ) {
                        $table.tablesorter(
                                { sortList: [
        tableTest(
                'Sort via click event after having initialized the tablesorter with initial sorting',
                header,
-               initial,
-               descasc,
+               simple,
+               simpleDescasc,
                function ( $table ) {
                        $table.tablesorter(
                                { sortList: [ { 0: 'asc' }, { 1: 'asc' } ] }
        tableTest(
                'Multi-sort via click event after having initialized the tablesorter with initial sorting',
                header,
-               initial,
-               asc,
+               simple,
+               simpleAsc,
                function ( $table ) {
                        $table.tablesorter(
                                { sortList: [ { 0: 'desc' }, { 1: 'desc' } ] }
                }
        );
        QUnit.test( 'Reset sorting making table appear unsorted', 3, function ( assert ) {
-               var $table = tableCreate( header, initial );
+               var $table = tableCreate( header, simple );
                $table.tablesorter(
                        { sortList: [
                                { 0: 'desc' },
        } );
 
        // Sorting with colspans
-       header = [ 'column1a' , 'column1b', 'column1c', 'column2' ];
-       var
-               aaa1 = [ 'A', 'A', 'A', '1' ],
-               aab5 = [ 'A', 'A', 'B', '5' ],
-               abc3 = [ 'A', 'B', 'C', '3' ],
-               bbc2 = [ 'B', 'B', 'C', '2' ],
-               caa4 = [ 'C', 'A', 'A', '4' ];
-       // initial is already declared above
-       initial = [ aab5, aaa1, abc3, bbc2, caa4 ];
+       header = [ 'column1a', 'column1b', 'column1c', 'column2' ];
+
        tableTest( 'Sorting with colspanned headers: spanned column',
                header,
-               initial,
+               colspanInitial,
                [ aaa1, aab5, abc3, bbc2, caa4 ],
                function ( $table ) {
                        // Make colspanned header for test
        );
        tableTest( 'Sorting with colspanned headers: sort spanned column twice',
                header,
-               initial,
+               colspanInitial,
                [ caa4, bbc2, abc3, aab5, aaa1 ],
                function ( $table ) {
                        // Make colspanned header for test
        );
        tableTest( 'Sorting with colspanned headers: subsequent column',
                header,
-               initial,
+               colspanInitial,
                [ aaa1, bbc2, abc3, caa4, aab5 ],
                function ( $table ) {
                        // Make colspanned header for test
        );
        tableTest( 'Sorting with colspanned headers: sort subsequent column twice',
                header,
-               initial,
+               colspanInitial,
                [ aab5, caa4, abc3, bbc2, aaa1 ],
                function ( $table ) {
                        // Make colspanned header for test
                }
        );
 
-
        tableTest(
                'Basic planet table: one unsortable column',
                header,
                }
        );
 
-       var ipv4 = [
-               // Some randomly generated fake IPs
-               ['45.238.27.109'],
-               ['44.172.9.22'],
-               ['247.240.82.209'],
-               ['204.204.132.158'],
-               ['170.38.91.162'],
-               ['197.219.164.9'],
-               ['45.68.154.72'],
-               ['182.195.149.80']
-       ];
-       var ipv4Sorted = [
-               // Sort order should go octet by octet
-               ['44.172.9.22'],
-               ['45.68.154.72'],
-               ['45.238.27.109'],
-               ['170.38.91.162'],
-               ['182.195.149.80'],
-               ['197.219.164.9'],
-               ['204.204.132.158'],
-               ['247.240.82.209']
-       ];
-
        tableTest(
                'Bug 17141: IPv4 address sorting',
                ['IP'],
                }
        );
 
-       var umlautWords = [
-               // Some words with Umlauts
-               ['Günther'],
-               ['Peter'],
-               ['Björn'],
-               ['Bjorn'],
-               ['Apfel'],
-               ['Äpfel'],
-               ['Strasse'],
-               ['Sträßschen']
-       ];
-
-       var umlautWordsSorted = [
-               // Some words with Umlauts
-               ['Äpfel'],
-               ['Apfel'],
-               ['Björn'],
-               ['Bjorn'],
-               ['Günther'],
-               ['Peter'],
-               ['Sträßschen'],
-               ['Strasse']
-       ];
-
        tableTest(
                'Accented Characters with custom collation',
                ['Name'],
                );
        } );
 
-       var planetsRowspan = [
+       planetsRowspan = [
                [ 'Earth', '6051.8' ],
                jupiter,
                [ 'Mars', '6051.8' ],
                saturn,
                venus
        ];
-       var planetsRowspanII = [ jupiter, mercury, saturn, venus, [ 'Venus', '6371.0' ], [ 'Venus', '3390.0' ] ];
+       planetsRowspanII = [ jupiter, mercury, saturn, venus, [ 'Venus', '6371.0' ], [ 'Venus', '3390.0' ] ];
 
        tableTest(
                'Basic planet table: same value for multiple rows via rowspan',
                }
        );
 
-       var complexMDYDates = [
-               // Some words with Umlauts
-               ['January, 19 2010'],
-               ['April 21 1991'],
-               ['04 22 1991'],
-               ['5.12.1990'],
-               ['December 12 \'10']
-       ];
-
-       var complexMDYSorted = [
-               ['5.12.1990'],
-               ['April 21 1991'],
-               ['04 22 1991'],
-               ['January, 19 2010'],
-               ['December 12 \'10']
-       ];
-
        tableTest(
                'Complex date parsing I',
                ['date'],
                }
        );
 
-       var currencyUnsorted = [
-               ['1.02 $'],
-               ['$ 3.00'],
-               ['€ 2,99'],
-               ['$ 1.00'],
-               ['$3.50'],
-               ['$ 1.50'],
-               ['€ 0.99']
-       ];
-
-       var currencySorted = [
-               ['€ 0.99'],
-               ['$ 1.00'],
-               ['1.02 $'],
-               ['$ 1.50'],
-               ['$ 3.00'],
-               ['$3.50'],
-               // Comma's sort after dots
-               // Not intentional but test to detect changes
-               ['€ 2,99']
-       ];
-
        tableTest(
                'Currency parsing I',
                ['currency'],
                }
        );
 
-       var ascendingNameLegacy = ascendingName.slice( 0 );
-       ascendingNameLegacy[4] = ascendingNameLegacy[5];
-       ascendingNameLegacy.pop();
+       planetsAscNameLegacy = planetsAscName.slice( 0 );
+       planetsAscNameLegacy[4] = planetsAscNameLegacy[5];
+       planetsAscNameLegacy.pop();
 
        tableTest(
                'Legacy compat with .sortbottom',
                header,
                planets,
-               ascendingNameLegacy,
+               planetsAscNameLegacy,
                function ( $table ) {
                        $table.find( 'tr:last' ).addClass( 'sortbottom' );
                        $table.tablesorter();
 
        } );
 
-       var numbers = [
-               [ '12'    ],
-               [  '7'    ],
-               [ '13,000'],
-               [  '9'    ],
-               [ '14'    ],
-               [  '8.0'  ]
-       ];
-       var numbersAsc = [
-               [  '7'    ],
-               [  '8.0'  ],
-               [  '9'    ],
-               [ '12'    ],
-               [ '14'    ],
-               [ '13,000']
-       ];
-
        tableTest( 'bug 8115: sort numbers with commas (ascending)',
                ['Numbers'], numbers, numbersAsc,
                function ( $table ) {
                );
        } );
 
-
-       var correctDateSorting1 = [
-               ['01 January 2010'],
-               ['05 February 2010'],
-               ['16 January 2010']
-       ];
-
-       var correctDateSortingSorted1 = [
-               ['01 January 2010'],
-               ['16 January 2010'],
-               ['05 February 2010']
-       ];
-
        tableTest(
                'Correct date sorting I',
                ['date'],
                }
        );
 
-       var correctDateSorting2 = [
-               ['January 01 2010'],
-               ['February 05 2010'],
-               ['January 16 2010']
-       ];
-
-       var correctDateSortingSorted2 = [
-               ['January 01 2010'],
-               ['January 16 2010'],
-               ['February 05 2010']
-       ];
-
        tableTest(
                'Correct date sorting II',
                ['date'],