Page MenuHomePhabricator

mw.util.getUrl changes double $ signs to a single $ sign
Closed, ResolvedPublic


> mw.util.getUrl('Test$$hello$$')


Related Gerrit Patches:

Event Timeline

TTO created this task.Nov 2 2016, 2:39 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptNov 2 2016, 2:39 AM

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

The fix would be something so simple and awkward as this:

url = mw.config.get( 'wgArticlePath' ).replace( '$1', util.wikiUrlencode( title ).replace(/\$/g,'$$$$') );

Change 319266 had a related patch set uploaded (by TTO):
mediawiki.util: Fix replacement of $ signs in mw.util.getUrl

TTO added a comment.Nov 2 2016, 3:22 AM

Thanks for the sleuthing work!

matmarex closed this task as Resolved.Nov 2 2016, 9:49 AM
matmarex assigned this task to TTO.
matmarex removed a project: Patch-For-Review.

Good catch.

An alternative is:

url = mw.config.get( 'wgArticlePath' ).replace( '$1', function () {
	return util.wikiUrlencode( title );
} );

Change 319266 merged by jenkins-bot:
mediawiki.util: Fix replacement of $ signs in mw.util.getUrl