diff --git a/core/includes/common.inc b/core/includes/common.inc
index f2a4003..f6eea60 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -486,17 +486,18 @@ function drupal_http_build_query(array $query, $parent = '') {
     if (is_array($value)) {
       $params[] = drupal_http_build_query($value, $key);
     }
-    // If a query parameter value is NULL, only append its key.
-    elseif (!isset($value)) {
+    // If a query parameter value is empty string, only append its key.
+    elseif (isset($value) && $value==='') {
       $params[] = $key;
     }
-    else {
+    elseif (isset($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/GotoTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/GotoTest.php
index 16ffccd..cc04989 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/GotoTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/GotoTest.php
@@ -72,7 +72,7 @@ class GotoTest extends WebTestBase {
     $this->assertText('The destination: ' . $query, t('The given query string destination is determined as destination.'));
 
     // Verify that the current path is used as destination.
-    $this->drupalGet('common-test/destination', array('query' => array($query => NULL)));
+    $this->drupalGet('common-test/destination', array('query' => array($query => '')));
     $url = 'common-test/destination?' . $query;
     $this->assertText('The destination: ' . $url, t('The current path is determined as destination.'));
   }
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..a88dc5e 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' => '',
+      'f' => '2',
+    );
+    $this->assertEqual(drupal_http_build_query($query), 'a=1&e&f=2', 'Empty query parameter values are properly ignored.');
   }
 
   /**
@@ -163,16 +174,16 @@ class UrlTest extends WebTestBase {
         $result = url('node/123', array('fragment' => 'foo', 'absolute' => $absolute));
         $this->assertEqual($url, $result, "$url == $result");
 
-        $url = $base . 'node/123?foo';
-        $result = url('node/123', array('query' => array('foo' => NULL), 'absolute' => $absolute));
+        $url = $base . 'node/123?foo=';
+        $result = url('node/123', array('query' => array('foo' => ''), 'absolute' => $absolute));
         $this->assertEqual($url, $result, "$url == $result");
 
         $url = $base . 'node/123?foo=bar&bar=baz';
         $result = url('node/123', array('query' => array('foo' => 'bar', 'bar' => 'baz'), 'absolute' => $absolute));
         $this->assertEqual($url, $result, "$url == $result");
 
-        $url = $base . 'node/123?foo#bar';
-        $result = url('node/123', array('query' => array('foo' => NULL), 'fragment' => 'bar', 'absolute' => $absolute));
+        $url = $base . 'node/123?foo=#bar';
+        $result = url('node/123', array('query' => array('foo' => ''), 'fragment' => 'bar', 'absolute' => $absolute));
         $this->assertEqual($url, $result, "$url == $result");
 
         $url = $base;
