https://bugzilla.wikimedia.org/show_bug.cgi?id=31499
Web browser: ---
Bug #: 31499
Summary: WikiEditor articlePathRegex is invalid for internal
link detection in 1.17.0
Product: MediaWiki extensions
Version: any
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: Unprioritized
Component: WikiEditor
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
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:
http://mywiki.com/wiki/$1
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?
--
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l