Attempted to fix a bug where the port number was added twice to the URLs.
authorfidian <fidian@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 17 Oct 2000 18:29:01 +0000 (18:29 +0000)
committerfidian <fidian@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 17 Oct 2000 18:29:01 +0000 (18:29 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@803 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/strings.php

index e59f556e2f4e766cedb0700b0105e9301f8dd277..3b1ea5a805d9ce8f5310a7335cb827da26e4c125 100644 (file)
         $proto = "https://";
       }
    
-      $port = "";
-      if (isset($SERVER_PORT)) {
-        if ($SERVER_PORT != 80) {
-            $port = sprintf(':%d', $SERVER_PORT);
-        }
-      }
-          
       // Get the hostname from the Host header or server config.
+      $host = "";
+      if (isset($HTTP_HOST) && !empty($HTTP_HOST))
+      {
+          $host = $HTTP_HOST;
+      }
+      else if (isset($SERVER_NAME) && !empty($SERVER_NAME))
+      {
+          $host = $SERVER_NAME;
+      }
+      
+      // Workaround to possibly get rid of extra port definitions.
+      $port = '';
+      if (! strstr($host, ':'))
+      {
+          if (isset($SERVER_PORT)) {
+              if ($SERVER_PORT != 80) {
+                  $port = sprintf(':%d', $SERVER_PORT);
+              }
+          }
+      }
+      
+      if ($host)
+          return $proto . $host . $port . $path;
+
       // Fallback is to omit the server name and use a relative URI,
       // although this is not RFC 2616 compliant.
-      if(isset($HTTP_HOST) && !empty($HTTP_HOST)) {
-        $location = $proto . $HTTP_HOST . $port . $path;
-      } else if(isset($SERVER_NAME) && !empty($SERVER_NAME)) {
-        $location = $proto . $SERVER_NAME . $port . $path;
-      } else {
-        $location = $path;
-      }
-      return $location;
+      return $path;    
    }   
 
    function sqStripSlashes($string) {