diff --git a/core/lib/Drupal/Component/Utility/UrlHelper.php b/core/lib/Drupal/Component/Utility/UrlHelper.php
index 1763c23..47c3470 100755
--- a/core/lib/Drupal/Component/Utility/UrlHelper.php
+++ b/core/lib/Drupal/Component/Utility/UrlHelper.php
@@ -55,12 +55,17 @@ public static function buildQuery(array $query, $parent = '') {
 
       // Recurse into children.
       if (is_array($value)) {
-        $params[] = static::buildQuery($value, $key);
+        if ($children_query = static::buildQuery($value, $key)) {
+          $params[] = $children_query;
+        }
       }
-      // If a query parameter value is NULL, only append its key.
-      elseif (!isset($value)) {
+      // If a query parameter value is not set, only append its key.
+      elseif (!isset($value) && !empty($key)) {
         $params[] = $key;
       }
+      elseif ($value === NULL ) {
+        // Skip NULL values.
+      }
       else {
         // For better readability of paths in query strings, we decode slashes.
         $params[] = $key . '=' . str_replace('%2F', '/', rawurlencode($value));
diff --git a/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php b/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
index 761fa69..8343305 100755
--- a/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
@@ -28,7 +28,10 @@ public function providerTestBuildQuery() {
       array(array(' &#//+%20@۞' => 'a'), '%20%26%23%2F%2F%2B%2520%40%DB%9E=a', 'Key was properly encoded.'),
       array(array('a' => '1', 'b' => '2', 'c' => '3'), 'a=1&b=2&c=3', 'Multiple values were properly concatenated.'),
       array(array('a' => array('b' => '2', 'c' => '3'), 'd' => 'foo'), 'a[b]=2&a[c]=3&d=foo', 'Nested array was properly encoded.'),
-      array(array('foo' => NULL), 'foo', 'Simple parameters are properly added.'),
+      array(array('a' => '1', 'b' => array('c' => array()), 'd' => NULL, 'e' => '', 'f' => '2'), 'a=1&d&e=&f=2', 'Empty query parameter values are properly ignored.'),
+      array(array('foo' => ''), 'foo=', 'Simple parameters are properly added.'),
+      array(array('foo' => NULL), 'foo', 'Empty parameters are not added.'),
+      array(array('' => NULL), '', 'Empty parameters are not added.'),
     );
   }
 
@@ -46,7 +49,7 @@ public function providerTestBuildQuery() {
    *   The assertion message.
    */
   public function testBuildQuery($query, $expected, $message) {
-    $this->assertEquals(UrlHelper::buildQuery($query), $expected, $message);
+    $this->assertEquals($expected, UrlHelper::buildQuery($query), $message);
   }
 
   /**
