ISSUE

When using TCP port based virtual hosts, the directory names being scanned for settings.php files contain a colon, e.g. "localhost:81". The colon is an annoying character in Unix environments, also it can be escaped. However, it is a real problem for Windows environments where it has a special meaning (separator between drive letter and path) and cannot be escaped.

SOLUTION

Replace the colon by something less problematic. The following patch replaces colon with underscore.

Index: drupal-4.6.9/includes/bootstrap.inc
--- drupal-4.6.9/includes/bootstrap.inc.orig    2005-11-30 11:05:16.000000000 +0100
+++ drupal-4.6.9/includes/bootstrap.inc 2006-08-15 16:21:33.490589154 +0200
@@ -54,6 +54,7 @@
   for ($i = count($uri) - 1; $i > 0; $i--) {
     for ($j = count($server); $j > 0; $j--) {
       $dir = implode('.', array_slice($server, -$j)) . implode('.', array_slice($uri, 0, $i));
+      $dir = str_replace(':', '_', $dir);
       if (file_exists("$confdir/$dir/settings.php")) {
         $conf = "$confdir/$dir";
         return $conf;

Comments

magico’s picture

Category: feature » bug
Status: Active » Needs review

I'm marking this as a bug, because it is a situation that affects all Windows hosting environment.

Steven’s picture

Hmmm, we already handle port numbers in $server in the lines above:

  $uri = explode('/', $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_FILENAME']);
  $server = explode('.', implode('.', array_reverse(explode(':', rtrim($_SERVER['HTTP_HOST'], '.')))));

Can you see if $_SERVER['SCRIPT_FILENAME'] or $_SERVER['PHP_SELF'] contain a colon?

Steven’s picture

Status: Needs review » Active
magico’s picture

Those lines exist in conf_path() for 4.7.3 but they are not present in conf_init() for 4.6.9
Probably a backport is needed?

In 4.6.9 the following code exists:

$confdir = 'sites';
$uri = explode('/', $_SERVER['PHP_SELF']);
$server = explode('.', rtrim($_SERVER['HTTP_HOST'], '.'));

In 4.7.3:

$confdir = 'sites';
$uri = explode('/', $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_FILENAME']);
$server = explode('.', implode('.', array_reverse(explode(':', rtrim($_SERVER['HTTP_HOST'], '.')))));
magico’s picture

Status: Active » Closed (fixed)

No one needs this because it is so "minor".