summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/core/URI.php40
-rw-r--r--user_guide_src/source/changelog.rst4
2 files changed, 23 insertions, 21 deletions
diff --git a/system/core/URI.php b/system/core/URI.php
index d67a35d4b..3d942eda7 100644
--- a/system/core/URI.php
+++ b/system/core/URI.php
@@ -185,37 +185,39 @@ class CI_URI {
return '';
}
- if (strpos($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME']) === 0)
- {
- $uri = substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME']));
- }
- elseif (strpos($_SERVER['REQUEST_URI'], dirname($_SERVER['SCRIPT_NAME'])) === 0)
+ $uri = parse_url($_SERVER['REQUEST_URI']);
+ $query = isset($uri['query']) ? $uri['query'] : '';
+ $uri = isset($uri['path']) ? $uri['path'] : '';
+
+ if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)
{
- $uri = substr($_SERVER['REQUEST_URI'], strlen(dirname($_SERVER['SCRIPT_NAME'])));
+ $uri = (string) substr($uri, strlen($_SERVER['SCRIPT_NAME']));
}
- else
+ elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0)
{
- $uri = $_SERVER['REQUEST_URI'];
+ $uri = (string) substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
}
-
// This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct
// URI is found, and also fixes the QUERY_STRING server var and $_GET array.
- if (strpos($uri, '?/') === 0)
+
+ if ($uri === '' && strncmp($query, '/', 1) === 0)
+ {
+ $query = explode('?', $query, 2);
+ $uri = $query[0];
+ $_SERVER['QUERY_STRING'] = isset($query[1]) ? $query[1] : '';
+ }
+ else
{
- $uri = substr($uri, 2);
+ $_SERVER['QUERY_STRING'] = $query;
}
- $parts = explode('?', $uri, 2);
- $uri = $parts[0];
- if (isset($parts[1]))
+ if ($_SERVER['QUERY_STRING'] === '')
{
- $_SERVER['QUERY_STRING'] = $parts[1];
- parse_str($_SERVER['QUERY_STRING'], $_GET);
+ $_GET = array();
}
else
{
- $_SERVER['QUERY_STRING'] = '';
- $_GET = array();
+ parse_str($_SERVER['QUERY_STRING'], $_GET);
}
if ($uri === '/' OR $uri === '')
@@ -223,8 +225,6 @@ class CI_URI {
return '/';
}
- $uri = parse_url('pseudo://hostname/'.$uri, PHP_URL_PATH);
-
// Do some final cleaning of the URI and return it
return str_replace(array('//', '../'), '/', trim($uri, '/'));
}
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 065daf54b..8e823d08d 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -230,7 +230,9 @@ Release Date: Not Released
- Core
- - Changed private methods in the :doc:`URI Library <libraries/uri>` to protected so MY_URI can override them.
+ - :doc:`URI Library <libraries/uri>` changes include:
+ - Changed private methods to protected so that MY_URI can override them.
+ - Changed ``_detect_uri()`` to accept absolute URIs for compatibility with HTTP/1.1 as per `RFC2616 <http://www.ietf.org/rfc/rfc2616.txt>`.
- Removed ``CI_CORE`` boolean constant from *CodeIgniter.php* (no longer Reactor and Core versions).
- :doc:`Loader Library <libraries/loader>` changes include:
- Added method ``get_vars()`` to the Loader to retrieve all variables loaded with ``$this->load->vars()``.