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

Unified Diff: components/url_formatter/url_fixer.cc

Issue 2378213002: Mark URLs with empty schemes as invalid. (Closed)
Patch Set: Comments 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: components/url_formatter/url_fixer.cc
diff --git a/components/url_formatter/url_fixer.cc b/components/url_formatter/url_fixer.cc
index 53abe4e0c4a910aa2a065160af3f35c0533352be..c49b31ba08cb4ee680a9498c64abbd69c728f9d6 100644
--- a/components/url_formatter/url_fixer.cc
+++ b/components/url_formatter/url_fixer.cc
@@ -480,7 +480,10 @@ std::string SegmentURLInternal(std::string* text, url::Parsed* parts) {
// Construct the text to parse by inserting the scheme.
std::string inserted_text(scheme);
- inserted_text.append(url::kStandardSchemeSeparator);
+ // Assume a leading colon was meant to be a scheme separator (which GURL will
+ // fix up for us into the full "://"). Otherwise add the separator ourselves.
+ if (first_nonwhite == text->end() || *first_nonwhite != ':')
+ inserted_text.append(url::kStandardSchemeSeparator);
std::string text_to_parse(text->begin(), first_nonwhite);
text_to_parse.append(inserted_text);
text_to_parse.append(first_nonwhite, text->end());
« no previous file with comments | « components/omnibox/browser/autocomplete_input_unittest.cc ('k') | components/url_formatter/url_fixer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698