r45727 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45726‎ | r45727 | r45728 >
Date:14:29, 14 January 2009
Author:aaron
Status:ok (Comments)
Tags:
Comment:
Bug 17011 Autolink URLs in CodeReview SVN commit messages
Modified paths:
  • /trunk/extensions/CodeReview/SpecialCode.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/SpecialCode.php
@@ -171,12 +171,21 @@
172172 }
173173
174174 function link( $text ) {
 175+ # Catch links like http://www.mediawiki.org/wiki/Special:Code/MediaWiki/44245#c829
 176+ # Ended by space or brackets (like those pesky <br/> tags)
 177+ $text = preg_replace_callback( '/(\b)('.wfUrlProtocols().')([^ <>]+)(\b)/', array( $this, 'generalLink' ), $text );
175178 $text = preg_replace_callback( '/\br(\d+)\b/', array( $this, 'messageRevLink' ), $text );
176179 $text = preg_replace_callback( '/\bbug #?(\d+)\b/i', array( $this, 'messageBugLink' ), $text );
177180 return $text;
178181 }
 182+
 183+ function generalLink( $arr ) {
 184+ $url = $arr[2] . $arr[3];
 185+ // Re-add the surrounding space/punctuation
 186+ return $arr[1] . $this->makeExternalLink( $url, $url ). $arr[4];
 187+ }
179188
180 - function messageBugLink( $arr ){
 189+ function messageBugLink( $arr ) {
181190 $text = $arr[0];
182191 $bugNo = intval( $arr[1] );
183192 $url = $this->mRepo->getBugPath( $bugNo );

Comments

#Comment by Brion VIBBER (talk | contribs)   01:12, 15 January 2009

Yay!

Status & tagging log