r94372 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94371‎ | r94372 | r94373 >
Date:19:19, 12 August 2011
Author:catrope
Status:ok (Comments)
Tags:
Comment:
Instead of using some hacky regexes, just use wfParseUrl() in WikiMap::getDisplayName(). This should make protocol-relative URLs behave correctly as well, and fix bug 29965
Modified paths:
  • /trunk/phase3/includes/WikiMap.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/WikiMap.php
@@ -129,11 +129,13 @@
130130 */
131131 public function getDisplayName() {
132132 $url = $this->getUrl( '' );
133 - $url = preg_replace( '!^https?://!', '', $url );
134 - $url = preg_replace( '!/index\.php(\?title=|/)$!', '/', $url );
135 - $url = preg_replace( '!/wiki/$!', '/', $url );
136 - $url = preg_replace( '!/$!', '', $url );
137 - return $url;
 133+ $parsed = wfParseUrl( $url );
 134+ if ( $parsed ) {
 135+ return $parsed['host'];
 136+ } else {
 137+ // Invalid URL. There's no sane thing to do here, so just return it
 138+ return $url;
 139+ }
138140 }
139141
140142 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r94446MFT to REL1_18:...hashar09:27, 14 August 2011
r945571.17wmf1: MFT r87099, r90729, r93141, r93517, r93891, r94155, r94277, r94372catrope20:12, 15 August 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   20:58, 12 August 2011

lol

Status & tagging log