r101050 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101049‎ | r101050 | r101051 >
Date:20:55, 27 October 2011
Author:preilly
Status:ok (Comments)
Tags:
Comment:
fix protocol-relative url issue
Modified paths:
  • /trunk/extensions/MobileFrontend/MobileFrontend.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/MobileFrontend.php
@@ -365,7 +365,7 @@
366366 $queryDelimiter = ( !empty( $parsedUrl['query'] ) ) ? '?' : '';
367367 $languageUrl = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $parsedUrl['path'] . $queryDelimiter . $parsedUrl['query'] . $fragmentDelimiter . $parsedUrl['fragment'];
368368
369 - if ( substr( $languageUrl, 0, 1 ) == ':') {
 369+ if ( substr( $languageUrl, 0, 1 ) == ':' ) {
370370 $languageUrl = substr( $languageUrl, 1 );
371371 }
372372

Comments

#Comment by Johnduhart (talk | contribs)   20:56, 27 October 2011
-			if ( substr( $languageUrl, 0, 1 ) == ':') {
+			if ( substr( $languageUrl, 0, 1 ) == ':' ) {

Huh?

#Comment by Preilly (talk | contribs)   21:07, 27 October 2011

Just added a missing space.

#Comment by Johnduhart (talk | contribs)   23:33, 27 October 2011

No I see that it's just I'm wondering how that fixed the issue

#Comment by Preilly (talk | contribs)   23:52, 27 October 2011

So, the code was like: $parsedUrl['scheme'] . '://' . $parsedUrl['host']... and because of protocol-relative urls $parsedUrl['scheme'] was empty. So, the urls were like, "://en.m.wikipedia.org/...". So, what I did was check to see if the first character of the string was, ":" if it is just give everything but the initial, ":". This made , "://en.m.wikipedia.org/..." correctly be, "//en.m.wikipedia.org/...". Does that make sense?

#Comment by Nikerabbit (talk | contribs)   06:53, 28 October 2011

He's talking how the commit message does not match the actual change in the code.

#Comment by Catrope (talk | contribs)   08:12, 28 October 2011

You don't need this, use $parsedUrl['delimiter']. This will be set to '://' or '//' as appropriate. See also the documentation for wfParseUrl() in GlobalFunctions.php

#Comment by Preilly (talk | contribs)   17:26, 28 October 2011

This is now fixed in r101154.

Status & tagging log