mediawiki.util: Fix replacement of $ signs in mw.util.getUrl
authorThis, that and the other <at.light@live.com.au>
Wed, 2 Nov 2016 03:31:08 +0000 (14:31 +1100)
committerThis, that and the other <at.light@live.com.au>
Wed, 2 Nov 2016 03:31:08 +0000 (14:31 +1100)
Bug: T149767
Change-Id: I91c1afa1f93966d1f01793d124fe8f2ae3dab0cf

resources/src/mediawiki/mediawiki.util.js
tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js

index 866f213..654f232 100644 (file)
                                        ? util.wikiScript() + '?title=' + util.wikiUrlencode( title ) + '&' + query
                                        : util.wikiScript() + '?' + query;
                        } else {
-                               url = mw.config.get( 'wgArticlePath' ).replace( '$1', util.wikiUrlencode( title ) );
+                               url = mw.config.get( 'wgArticlePath' )
+                                       .replace( '$1', util.wikiUrlencode( title ).replace( /\$/g, '$$$$' ) );
                        }
 
                        // Append the encoded fragment
index 4eac362..6dd17f1 100644 (file)
                } );
        } );
 
-       QUnit.test( 'getUrl', 13, function ( assert ) {
+       QUnit.test( 'getUrl', 14, function ( assert ) {
                var href;
                mw.config.set( {
                        wgScript: '/w/index.php',
                href = mw.util.getUrl( 'Foo:Sandbox? 5+5=10! (test)/sub ' );
                assert.equal( href, '/wiki/Foo:Sandbox%3F_5%2B5%3D10!_(test)/sub_', 'complex title' );
 
+               // T149767
+               href = mw.util.getUrl( 'My$$test$$$$$title' );
+               assert.equal( href, '/wiki/My$$test$$$$$title', 'title with multiple consecutive dollar signs' );
+
                href = mw.util.getUrl();
                assert.equal( href, '/wiki/Foobar', 'default title' );