From 7aab0ab3680734e2973ce66da5486e1e6f233605 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Tue, 23 Nov 2010 03:08:34 +0000 Subject: - Patch #557298 by Arancaytar, David_Rothstein: drupal_override_server_variables() does not properly override SCRIPT_NAME. --- includes/bootstrap.inc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'includes/bootstrap.inc') diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index 3c550b759..9060a0e20 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -443,21 +443,23 @@ function conf_path($require_settings = TRUE, $reset = FALSE) { * @see ip_address() */ function drupal_override_server_variables($variables = array()) { - // Set defaults based on the provided URL. + // Allow the provided URL to override any existing values in $_SERVER. if (isset($variables['url'])) { $url = parse_url($variables['url']); + if (isset($url['host'])) { + $_SERVER['HTTP_HOST'] = $url['host']; + } + if (isset($url['path'])) { + $_SERVER['SCRIPT_NAME'] = $url['path']; + } unset($variables['url']); } - else { - $url = array(); - } - $url += array( - 'path' => '', - 'host' => 'localhost', - ); + // Define default values for $_SERVER keys. These will be used if $_SERVER + // does not already define them and no other values are passed in to this + // function. $defaults = array( - 'HTTP_HOST' => $url['host'], - 'SCRIPT_NAME' => $url['path'], + 'HTTP_HOST' => 'localhost', + 'SCRIPT_NAME' => NULL, 'REMOTE_ADDR' => '127.0.0.1', 'REQUEST_METHOD' => 'GET', 'SERVER_NAME' => NULL, -- cgit v1.2.3