diff options
-rw-r--r-- | chrome/browser/chrome_content_browser_client.cc | 7 | ||||
-rw-r--r-- | chrome/browser/chrome_content_browser_client_browsertest.cc | 24 |
2 files changed, 24 insertions, 7 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 588a4ea..f6c95e4 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -280,8 +280,15 @@ bool RemoveUberHost(GURL* url) { new_path = old_path.substr(separator); } + // Do not allow URLs with paths empty before the first slash since we can't + // have an empty host. (e.g "foo://chrome//") + if (new_host.empty()) + return false; + *url = ReplaceURLHostAndPath(*url, new_host, new_path); + DCHECK(url->is_valid()); + return true; } diff --git a/chrome/browser/chrome_content_browser_client_browsertest.cc b/chrome/browser/chrome_content_browser_client_browsertest.cc index d7bfa51..a8b6bbb 100644 --- a/chrome/browser/chrome_content_browser_client_browsertest.cc +++ b/chrome/browser/chrome_content_browser_client_browsertest.cc @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <string> - #include "base/command_line.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" @@ -29,8 +27,8 @@ class ChromeContentBrowserClientBrowserTest : public InProcessBrowserTest { IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest, UberURLHandler_SettingsPage) { - const GURL url_short(std::string("chrome://settings/")); - const GURL url_long(std::string("chrome://chrome/settings/")); + const GURL url_short("chrome://settings/"); + const GURL url_long("chrome://chrome/settings/"); ui_test_utils::NavigateToURL(browser(), url_short); NavigationEntry* entry = GetLastCommittedEntry(); @@ -42,8 +40,8 @@ IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest, IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest, UberURLHandler_ContentSettingsPage) { - const GURL url_short(std::string("chrome://settings/content")); - const GURL url_long(std::string("chrome://chrome/settings/content")); + const GURL url_short("chrome://settings/content"); + const GURL url_long("chrome://chrome/settings/content"); ui_test_utils::NavigateToURL(browser(), url_short); NavigationEntry* entry = GetLastCommittedEntry(); @@ -55,7 +53,7 @@ IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest, IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest, UberURLHandler_AboutPage) { - const GURL url(std::string("chrome://chrome/")); + const GURL url("chrome://chrome/"); ui_test_utils::NavigateToURL(browser(), url); NavigationEntry* entry = GetLastCommittedEntry(); @@ -65,6 +63,18 @@ IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest, EXPECT_EQ(url, entry->GetVirtualURL()); } +IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest, + UberURLHandler_EmptyHost) { + const GURL url("chrome://chrome//foo"); + + ui_test_utils::NavigateToURL(browser(), url); + NavigationEntry* entry = GetLastCommittedEntry(); + + ASSERT_TRUE(entry != NULL); + EXPECT_TRUE(entry->GetVirtualURL().is_valid()); + EXPECT_EQ(url, entry->GetVirtualURL()); +} + // Test that a basic navigation works in --site-per-process mode. This prevents // regressions when that mode calls out into the ChromeContentBrowserClient, // such as http://crbug.com/164223. |