> mw.util.getUrl('Test$$hello$$') "/wiki/Test$hello$"
Description
Description
Details
Details
Subject | Repo | Branch | Lines +/- | |
---|---|---|---|---|
mediawiki.util: Fix replacement of $ signs in mw.util.getUrl | mediawiki/core | master | +7 -2 |
Event Timeline
Comment Actions
The problem is at this line:
url = mw.config.get( 'wgArticlePath' ).replace( '$1', util.wikiUrlencode( title ) );
Exactly in the String.replace function. $$ comes in the replacement string, which has a special meaning. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_string_as_a_parameter
The fix would be something so simple and awkward as this:
url = mw.config.get( 'wgArticlePath' ).replace( '$1', util.wikiUrlencode( title ).replace(/\$/g,'$$$$') );
Comment Actions
Change 319266 had a related patch set uploaded (by TTO):
mediawiki.util: Fix replacement of $ signs in mw.util.getUrl
Comment Actions
Good catch.
An alternative is:
url = mw.config.get( 'wgArticlePath' ).replace( '$1', function () { return util.wikiUrlencode( title ); } );
Comment Actions
Change 319266 merged by jenkins-bot:
mediawiki.util: Fix replacement of $ signs in mw.util.getUrl