Kelson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/117699

Change subject: Fix mobile/desktop view choices substainability on 3 parts 
domain names (like wikimedia.org.uk) #54885
......................................................................

Fix mobile/desktop view choices substainability on 3 parts domain names (like 
wikimedia.org.uk) #54885

Change-Id: I4cc4faf6c6f80571a65483299e04c596a7c1a5f8
---
M includes/MobileContext.php
1 file changed, 9 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/99/117699/1

diff --git a/includes/MobileContext.php b/includes/MobileContext.php
index b65140d..ad19f00 100644
--- a/includes/MobileContext.php
+++ b/includes/MobileContext.php
@@ -493,11 +493,7 @@
                $host = $parsedUrl['host'];
                // Validates value as IP address
                if ( !IP::isValid( $host ) ) {
-                       $domainParts = explode( '.', $host );
-                       $domainParts = array_reverse( $domainParts );
-                       // Although some browsers will accept cookies without 
the initial ., ยป RFC 2109 requires it to be included.
-                       wfProfileOut( __METHOD__ );
-                       return count( $domainParts ) >= 2 ? '.' . 
$domainParts[1] . '.' . $domainParts[0] : $host;
+                       return substr( $host, strpos( $host, "." ) );
                }
                wfProfileOut( __METHOD__ );
                return $host;
@@ -511,10 +507,15 @@
         * @return string
         */
        public function getStopMobileRedirectCookieDomain() {
-               global $wgMFStopRedirectCookieHost;
+               global $wgMFStopRedirectCookieHost, $wgMFCookieDomain;
+               $host = $this->getRequest()->getHeader( 'Host' );
 
-               if ( !$wgMFStopRedirectCookieHost ) {
-                       $wgMFStopRedirectCookieHost = $this->getBaseDomain();
+               if ( !$wgMFStopRedirectCookieHost || 
$wgMFStopRedirectCookieHost != $host ) {
+                       if ( $wgMFCookieDomain && ( strpos( $host, 
$wgMFCookieDomain ) !== false )) {
+                               $wgMFStopRedirectCookieHost = $wgMFCookieDomain;
+                       } else {
+                               $wgMFStopRedirectCookieHost = 
$this->getBaseDomain();
+                       }
                }
 
                return $wgMFStopRedirectCookieHost;

-- 
To view, visit https://gerrit.wikimedia.org/r/117699
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4cc4faf6c6f80571a65483299e04c596a7c1a5f8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Kelson <kel...@kiwix.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to