diff --git a/core/lib/Drupal/Component/Utility/UrlHelper.php b/core/lib/Drupal/Component/Utility/UrlHelper.php
index bd550460f916837342c6694a7ed0f6126fb32666..e3c9ab235aecb9b22c827a20b1a996a045d39c6f 100644
--- a/core/lib/Drupal/Component/Utility/UrlHelper.php
+++ b/core/lib/Drupal/Component/Utility/UrlHelper.php
@@ -154,7 +154,7 @@ public static function parse($url) {
       }
 
       // Split off everything before the query string into 'path'.
-      $parts = explode('?', $url);
+      $parts = explode('?', $url, 2);
 
       // Don't support URLs without a path, like 'http://'.
       list(, $path) = explode('://', $parts[0], 2);
diff --git a/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php b/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
index 594344f39e51f1bc85c768d3719b600c7bea2c26..7b9bd1c40e790e833e6f64b1bc9ed9c55e9d5032 100644
--- a/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
@@ -311,6 +311,42 @@ public static function providerTestParse() {
           'fragment' => 'footer',
         ],
       ],
+      'URL with two question marks, not encoded' => [
+        'http://www.example.com/my/path?destination=home&search=http://www.example.com/search?limit=10#footer',
+        [
+          'path' => 'http://www.example.com/my/path',
+          'query' => [
+            'destination' => 'home',
+            'search' => 'http://www.example.com/search?limit=10',
+          ],
+          'fragment' => 'footer',
+        ],
+      ],
+      'URL with three question marks, not encoded' => [
+        'http://www.example.com/my/path?destination=home&search=http://www.example.com/search?limit=10&referer=http://www.example.com/my/path?destination=home&other#footer',
+        [
+          'path' => 'http://www.example.com/my/path',
+          'query' => [
+            'destination' => 'home',
+            'search' => 'http://www.example.com/search?limit=10',
+            'referer' => 'http://www.example.com/my/path?destination=home',
+            'other' => '',
+          ],
+          'fragment' => 'footer',
+        ],
+      ],
+      'URL with three question marks, encoded' => [
+        'http://www.example.com/my/path?destination=home&search=http://www.example.com/search?limit=10&referer=http%3A%2F%2Fwww.example.com%2Fmy%2Fpath%3Fdestination%3Dhome%26other#footer',
+        [
+          'path' => 'http://www.example.com/my/path',
+          'query' => [
+            'destination' => 'home',
+            'search' => 'http://www.example.com/search?limit=10',
+            'referer' => 'http://www.example.com/my/path?destination=home&other',
+          ],
+          'fragment' => 'footer',
+        ],
+      ],
     ];
   }