r49653 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49652‎ | r49653 | r49654 >
Date:22:20, 19 April 2009
Author:rememberthedot
Status:reverted (Comments)
Tags:
Comment:
Make the link regex non-greedy so that it is possible to add '|' to $wgLegalTitleChars and still be able to pipe
links. This change should have no effect on the default configuration, which does not include '|' in
$wgLegalTitleChars because including it still breaks other things.
Modified paths:
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -1460,7 +1460,7 @@
14611461 if ( !$tc ) {
14621462 $tc = Title::legalChars() . '#%';
14631463 # Match a link having the form [[namespace:link|alternate]]trail
1464 - $e1 = "/^([{$tc}]+)(?:\\|(.+?))?]](.*)\$/sD";
 1464+ $e1 = "/^([{$tc}]+?)(?:\\|(.+?))?]](.*)\$/sD";
14651465 # Match cases where there is no "]]", which might still be images
14661466 $e1_img = "/^([{$tc}]+)\\|(.*)\$/sD";
14671467 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r50028Revert r49653 "Make the link regex non-greedy so that it is possible to add '...brion23:33, 28 April 2009

Comments

#Comment by Catrope (talk | contribs)   22:42, 19 April 2009

Note that titles containing '|' will break the API big time (and other things too, probably).

#Comment by Remember the dot (talk | contribs)   22:46, 19 April 2009

Yeah, much work remains to be done before we can safely use pipes in titles.

To clarify, if you add '|' to $wgLegalTitleChars then [[Mac|Life]] will still link to "Mac", but you will also be able to use [[Mac%7CLife]] to link to "Mac|Life". Previously, adding '|' to $wgLegalTitleChars broke all piped links.

#Comment by Catrope (talk | contribs)   22:50, 19 April 2009

Actually, I'm not sure it's desirable to support pipes in titles, ever. Of course Brion's word is final on this, but in my opinion it would simply break too much for little benefit.

#Comment by Remember the dot (talk | contribs)   23:31, 19 April 2009

Ideally, we'd use proper escaping so that pipes in titles could be integrated practically seamlessly. This would be useful for articles like en:MacLife, en:Torre Baró-Vallbona (Barcelona Metro), en:Softimage 3D, and en:El Maresme-Fòrum (Barcelona Metro). This revision that we're discussing is a small step toward that goal, and may prove useful to small wikis that don't mind the API breakage.

#Comment by 😂 (talk | contribs)   02:07, 22 April 2009

Fwiw, this doesn't cause any parser test regressions, but could probably use a parser test to check it :)

#Comment by Brion VIBBER (talk | contribs)   23:33, 28 April 2009

Reverted in r50028

Pipes would definitely not work in titles. The particular regex change here would for instance break image options if | were added to $wgLegalTitleChars.

Status & tagging log