diff --git a/core/includes/common.inc b/core/includes/common.inc
index edd7c2d..0c70164 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -478,12 +478,12 @@ function drupal_get_query_array($query) {
  * This differs from http_build_query() as we need to rawurlencode() (instead of
  * urlencode()) all query parameters.
  *
- * @param $query
+ * @param array $query
  *   The query parameter array to be processed, e.g. $_GET.
- * @param $parent
+ * @param string $parent
  *   Internal use only. Used to build the $query array key for nested items.
  *
- * @return
+ * @return string
  *   A rawurlencoded string which can be used as or appended to the URL query
  *   string.
  *
@@ -494,7 +494,7 @@ function drupal_http_build_query(array $query, $parent = '') {
   $params = array();
 
   foreach ($query as $key => $value) {
-    $key = ($parent ? $parent . '[' . rawurlencode($key) . ']' : rawurlencode($key));
+    $key = ($parent ? : '') . rawurlencode($parent ? '[' . $key . ']' : $key);
 
     // Recurse into children.
     if (is_array($value)) {
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php
index eeb49cc..6e351b0 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php
@@ -128,8 +128,10 @@ function testDrupalGetQueryParameters() {
   function testDrupalHttpBuildQuery() {
     $this->assertEqual(drupal_http_build_query(array('a' => ' &#//+%20@۞')), 'a=%20%26%23//%2B%2520%40%DB%9E', 'Value was properly encoded.');
     $this->assertEqual(drupal_http_build_query(array(' &#//+%20@۞' => 'a')), '%20%26%23%2F%2F%2B%2520%40%DB%9E=a', 'Key was properly encoded.');
-    $this->assertEqual(drupal_http_build_query(array('a' => '1', 'b' => '2', 'c' => '3')), 'a=1&b=2&c=3', 'Multiple values were properly concatenated.');
-    $this->assertEqual(drupal_http_build_query(array('a' => array('b' => '2', 'c' => '3'), 'd' => 'foo')), 'a[b]=2&a[c]=3&d=foo', 'Nested array was properly encoded.');
+    $test_for = array('a' => '1', 'b' => '2', 'c' => '3', 'd' => 'foo');
+    $this->assertEqual(drupal_http_build_query($test_for), 'a=1&b=2&c=3&d=foo', 'Multiple values were properly concatenated.');
+    $test_for = array('a' => array('b' => 2, 'c' => 3), 'd' => 'foo');
+    $this->assertEqual(drupal_http_build_query($test_for), 'a%5Bb%5D=2&a%5Bc%5D=3&d=foo', 'Nested array was properly encoded.');
   }
 
   /**
