r61581 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61580‎ | r61581 | r61582 >
Date:17:15, 27 January 2010
Author:platonides
Status:resolved (Comments)
Tags:
Comment:
Do not catch urls which begin with a bracket like [http://example.com this] / [http://example.com], since CodeCommentLinkerWiki then expands it to "[[http://example.com http://example.com] this] / [[http://example.com http://example.com]]" breaking badly.
Modified paths:
  • /trunk/extensions/CodeReview/backend/CodeCommentLinker.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/backend/CodeCommentLinker.php
@@ -11,7 +11,7 @@
1212 function link( $text ) {
1313 # Catch links like http://www.mediawiki.org/wiki/Special:Code/MediaWiki/44245#c829
1414 # Ended by space or brackets (like those pesky <br /> tags)
15 - $text = preg_replace_callback( '/(\b)(' . wfUrlProtocols() . ')([^ <>]+)(\b)/', array( $this, 'generalLink' ), $text );
 15+ $text = preg_replace_callback( '/([^\B[])(' . wfUrlProtocols() . ')([^ <>]+)(\b)/', array( $this, 'generalLink' ), $text );
1616 $text = preg_replace_callback( '/\br(\d+)\b/', array( $this, 'messageRevLink' ), $text );
1717 $text = preg_replace_callback( '/\bbug #?(\d+)\b/i', array( $this, 'messageBugLink' ), $text );
1818 return $text;

Follow-up revisions

RevisionCommit summaryAuthorDate
r61611Follow-up r61581. As P.Copp has pointed out, \b and \B don't work inside char...platonides22:52, 27 January 2010

Comments

#Comment by P.Copp (talk | contribs)   21:25, 27 January 2010

Note that assertions like \b and \B don't work as intended in character classes: <http://de.php.net/manual/en/regexp.reference.backslash.php>

You could probably use [^\w[] instead.

#Comment by Platonides (talk | contribs)   22:50, 27 January 2010

You are right, "These assertions may not appear in character classes".

It would convert ahttp://example.com into a[http://example.com [http://example.com http://example.com]].

It wouldn't be that bad, since the protocol is already quite specific, but it's not what was intended.

Status & tagging log