diff --git a/core/includes/common.inc b/core/includes/common.inc
index f2a4003..af15f5e 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -487,16 +487,14 @@ function drupal_http_build_query(array $query, $parent = '') {
       $params[] = drupal_http_build_query($value, $key);
     }
     // If a query parameter value is NULL, only append its key.
-    elseif (!isset($value)) {
-      $params[] = $key;
-    }
-    else {
+    elseif (isset($value) && $value !== '') {
       // For better readability of paths in query strings, we decode slashes.
       $params[] = $key . '=' . str_replace('%2F', '/', rawurlencode($value));
     }
   }
 
-  return implode('&', $params);
+  $params = array_filter($params);
+  return !empty($params) ? implode('&', $params) : NULL;
 }
 
 /**
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 131ce25..1aadb9b 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php
@@ -101,6 +101,17 @@ class UrlTest extends WebTestBase {
     $this->assertEqual(drupal_http_build_query(array(' &#//+%20@۞' => 'a')), '%20%26%23%2F%2F%2B%2520%40%DB%9E=a', t('Key was properly encoded.'));
     $this->assertEqual(drupal_http_build_query(array('a' => '1', 'b' => '2', 'c' => '3')), 'a=1&b=2&c=3', t('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', t('Nested array was properly encoded.'));
+
+    $query = array(
+      'a' => '1',
+      'b' => array(
+        'c' => array(),
+        'd' => NULL,
+      ),
+      'e' => '2',
+      'f' => '',
+    );
+    $this->assertEqual(drupal_http_build_query($query), 'a=1&e=2', 'Empty query parameter values are properly ignored.');
   }
 
   /**
