r100699 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100698‎ | r100699 | r100700 >
Date:14:30, 25 October 2011
Author:catrope
Status:ok (Comments)
Tags:
Comment:
(bug 31499) articlePathRegex (detection of external links within the same wiki) broken when wgServer is protocol-relative
Modified paths:
  • /trunk/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js
@@ -502,9 +502,11 @@
503503 }
504504 },
505505 open: function() {
 506+ // Obtain the server name without the protocol. wgServer may be protocol-relative
 507+ var serverName = mw.config.get( 'wgServer' ).replace( /^(https?:)?\/\//, '' );
506508 // Cache the articlepath regex
507509 $(this).data( 'articlePathRegex', new RegExp(
508 - '^' + $.escapeRE( mw.config.get( 'wgServer' ) + mw.config.get( 'wgArticlePath' ) )
 510+ '^https?://' + $.escapeRE( serverName + mw.config.get( 'wgArticlePath' ) )
509511 .replace( /\\\$1/g, '(.*)' ) + '$'
510512 ) );
511513 // Pre-fill the text fields based on the current selection

Follow-up revisions

RevisionCommit summaryAuthorDate
r102526REL1_18 MFT r100504, r100699reedy16:12, 9 November 2011
r102601MFT r100699reedy23:28, 9 November 2011

Comments

#Comment by NeilK (talk | contribs)   07:05, 8 November 2011

Evil, but it works.

Incidentally, mediawiki.Uri.js parses and creates protocol-relative URLs now. Not sure if it helps in this case.

#Comment by Catrope (talk | contribs)   10:29, 8 November 2011

mw.Uri might help, I'm not sure. The point of the regex is not to "just" parse the URL, but also to verify it conforms to $wgArticlePath and extract the page name.

Status & tagging log