Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Unified Diff: chrome/browser/ui/bookmarks/bookmark_utils.cc

Issue 2368593002: Prevent interpretating userinfo as url scheme when editing bookmarks (Closed)
Patch Set: Don't NULL when going away Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/bookmarks/bookmark_utils.cc
diff --git a/chrome/browser/ui/bookmarks/bookmark_utils.cc b/chrome/browser/ui/bookmarks/bookmark_utils.cc
index 13c2e18ab67b583d7f316d3e6d1730f19dd3a99b..ffebacaa0f6864fd57e0d0cda9b2dbb08552a13c 100644
--- a/chrome/browser/ui/bookmarks/bookmark_utils.cc
+++ b/chrome/browser/ui/bookmarks/bookmark_utils.cc
@@ -126,13 +126,20 @@ void ToggleBookmarkBarWhenVisible(content::BrowserContext* browser_context) {
base::string16 FormatBookmarkURLForDisplay(const GURL& url) {
// Because this gets re-parsed by FixupURL(), it's safe to omit the scheme
- // and trailing slash, and unescape most characters. However, it's
+ // and trailing slash, and unescape most characters. However, it's
// important not to drop any username/password, or unescape anything that
// changes the URL's meaning.
- return url_formatter::FormatUrl(
- url, url_formatter::kFormatUrlOmitAll &
- ~url_formatter::kFormatUrlOmitUsernamePassword,
- net::UnescapeRule::SPACES, nullptr, nullptr, nullptr);
+ url_formatter::FormatUrlTypes format_types =
+ url_formatter::kFormatUrlOmitAll &
+ ~url_formatter::kFormatUrlOmitUsernamePassword;
+
+ // If username is present, we must not omit the scheme because FixupURL() will
+ // subsequently interpret the username as a scheme. crbug.com/639126
+ if (url.has_username())
+ format_types &= ~url_formatter::kFormatUrlOmitHTTP;
+
+ return url_formatter::FormatUrl(url, format_types, net::UnescapeRule::SPACES,
+ nullptr, nullptr, nullptr);
}
bool IsAppsShortcutEnabled(Profile* profile) {
« no previous file with comments | « chrome/browser/ui/bookmarks/bookmark_utils.h ('k') | chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698