diff --git a/system/HTTP/URI.php b/system/HTTP/URI.php index 33f0081496e0..edf5525eab1d 100644 --- a/system/HTTP/URI.php +++ b/system/HTTP/URI.php @@ -749,80 +749,13 @@ public function setQuery(string $query) $query = substr($query, 1); } - $temp = explode('&', $query); - $parts = []; - - foreach ($temp as $index => $part) - { - list($key, $value) = $this->splitQueryPart($part); - - // Only 1 part? - if (is_null($value)) - { - $parts[$key] = null; - continue; - } - - // URL Decode the value to protect - // from double-encoding a URL. - // Especially useful with the Pager. - $parts[$this->decode($key)] = $this->decode($value); - } - - $this->query = $parts; + parse_str($query, $this->query); return $this; } //-------------------------------------------------------------------- - /** - * Checks the value to see if it has been urlencoded and decodes it if so. - * The urlencode check is not perfect but should catch most cases. - * - * @param string $value - * - * @return string - */ - protected function decode(string $value): string - { - if (empty($value)) - { - return $value; - } - - $decoded = urldecode($value); - - // This won't catch all cases, specifically - // changing ' ' to '+' has the same length - // but doesn't really matter for our cases here. - return strlen($decoded) < strlen($value) ? $decoded : $value; - } - - /** - * Split a query value into it's key/value elements, if both - * are present. - * - * @param $part - * - * @return array|null - */ - protected function splitQueryPart(string $part) - { - $parts = explode('=', $part, 2); - - // If there's only a single element, no pair, - // then we return null - if (count($parts) === 1) - { - $parts = null; - } - - return $parts; - } - - //-------------------------------------------------------------------- - /** * A convenience method to pass an array of items in as the Query * portion of the URI.