The code in WikiEditor for detecting "external internal" links like http://en.wikipedia.org/wiki/Foobar is broken due to an incorrect regular expression. The following code appears in ext.wikiEditor.dialogs.js in 1.17.0 (and in jquery.wikiEditor.dialogs.config.js in later MW versions):
$(this).data( 'articlePathRegex', new RegExp(
'^' + $.escapeRE( mw.config.get( 'wgServer' ) + mw.config.get( 'wgArticlePath' ) ) .replace( /\\\$1/g, '(.*)' ) + '$'
) );
The problem is that $.escapeRE converts this string:
into:
"^http\:\/\/mywiki\.com\/wiki\/\$\1$"
The problem is the slash before the "1". As a result, the replacement:
.replace( /\\\$1/g, '(.*)' ) + '$'
fails to match, so the $1 does not get replaced by "(.*)".
A quick fix would be to change the replace() call to:
.replace( /\\\$\\1/g, '(.*)' ) + '$'
but honestly, I don't understand why $.escapeRE turns "$1" into "\$\1". I think it should be turning it into "\$1". Maybe $1 has special meaning to $.escapeRE, as a back-reference or something?
Version: unspecified
Severity: normal