From 283bc520963db35173a452a32d5bd6296a7a0aa9 Mon Sep 17 00:00:00 2001
From: MashinaMashina <r-r-roma-a-a@yandex.ru>
Date: Fri, 17 Jan 2020 18:02:11 +0400
Subject: [PATCH 1/3] Fix splitQueryPart()

---
 system/HTTP/URI.php | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/system/HTTP/URI.php b/system/HTTP/URI.php
index 33f0081496e0..400be5f7500b 100644
--- a/system/HTTP/URI.php
+++ b/system/HTTP/URI.php
@@ -811,11 +811,9 @@ 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;
+			$parts[1] = '';
 		}
 
 		return $parts;

From 4bf27d85698c28813958d80f91483e07a8a9877d Mon Sep 17 00:00:00 2001
From: Morozov Roman <r-r-roma-a-a@yandex.ru>
Date: Sat, 18 Jan 2020 00:44:14 +0400
Subject: [PATCH 2/3] Empty  fix

---
 system/HTTP/URI.php | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/system/HTTP/URI.php b/system/HTTP/URI.php
index 400be5f7500b..771b5d3d5f1a 100644
--- a/system/HTTP/URI.php
+++ b/system/HTTP/URI.php
@@ -754,14 +754,10 @@ public function setQuery(string $query)
 
 		foreach ($temp as $index => $part)
 		{
-			list($key, $value) = $this->splitQueryPart($part);
-
-			// Only 1 part?
-			if (is_null($value))
-			{
-				$parts[$key] = null;
+			if ($part === '')
 				continue;
-			}
+			
+			list($key, $value) = $this->splitQueryPart($part);
 
 			// URL Decode the value to protect
 			// from double-encoding a URL.

From 7340963b36e704d44e72b9788338dae7abc758d9 Mon Sep 17 00:00:00 2001
From: MashinaMashina <r-r-roma-a-a@yandex.ru>
Date: Wed, 22 Jan 2020 09:37:44 +0400
Subject: [PATCH 3/3] Use parse_str instead more code

---
 system/HTTP/URI.php | 67 +--------------------------------------------
 1 file changed, 1 insertion(+), 66 deletions(-)

diff --git a/system/HTTP/URI.php b/system/HTTP/URI.php
index 400be5f7500b..edf5525eab1d 100644
--- a/system/HTTP/URI.php
+++ b/system/HTTP/URI.php
@@ -749,78 +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 (count($parts) === 1)
-		{
-			$parts[1] = '';
-		}
-
-		return $parts;
-	}
-
-	//--------------------------------------------------------------------
-
 	/**
 	 * A convenience method to pass an array of items in as the Query
 	 * portion of the URI.