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

Side by Side Diff: components/url_formatter/url_fixer.cc

Issue 1942613002: Change semicolon replace logic in url_fixer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/url_formatter/url_fixer.h" 5 #include "components/url_formatter/url_fixer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 #elif defined(OS_POSIX) 415 #elif defined(OS_POSIX)
416 if (base::FilePath::IsSeparator(trimmed.data()[0]) || 416 if (base::FilePath::IsSeparator(trimmed.data()[0]) ||
417 trimmed.data()[0] == '~') 417 trimmed.data()[0] == '~')
418 return url::kFileScheme; 418 return url::kFileScheme;
419 #endif 419 #endif
420 420
421 // Otherwise, we need to look at things carefully. 421 // Otherwise, we need to look at things carefully.
422 std::string scheme; 422 std::string scheme;
423 if (!GetValidScheme(*text, &parts->scheme, &scheme)) { 423 if (!GetValidScheme(*text, &parts->scheme, &scheme)) {
424 // Try again if there is a ';' in the text. If changing it to a ':' results 424 // Try again if there is a ';' in the text. If changing it to a ':' results
425 // in a scheme being found, continue processing with the modified text. 425 // in a standard scheme, "about", "chrome" or "file" scheme being found,
426 // continue processing with the modified text.
426 bool found_scheme = false; 427 bool found_scheme = false;
427 size_t semicolon = text->find(';'); 428 size_t semicolon = text->find(';');
428 if (semicolon != 0 && semicolon != std::string::npos) { 429 if (semicolon != 0 && semicolon != std::string::npos) {
429 (*text)[semicolon] = ':'; 430 (*text)[semicolon] = ':';
430 if (GetValidScheme(*text, &parts->scheme, &scheme)) 431 if (GetValidScheme(*text, &parts->scheme, &scheme) &&
432 (url::IsStandard(
433 scheme.c_str(),
434 url::Component(0, static_cast<int>(scheme.length()))) ||
435 scheme == url::kAboutScheme || scheme == kChromeUIScheme ||
436 scheme == url::kFileScheme))
431 found_scheme = true; 437 found_scheme = true;
432 else 438 else
433 (*text)[semicolon] = ';'; 439 (*text)[semicolon] = ';';
434 } 440 }
435 if (!found_scheme) { 441 if (!found_scheme) {
436 // Couldn't determine the scheme, so just pick one. 442 // Couldn't determine the scheme, so just pick one.
437 parts->scheme.reset(); 443 parts->scheme.reset();
438 scheme = 444 scheme =
439 base::StartsWith(*text, "ftp.", base::CompareCase::INSENSITIVE_ASCII) 445 base::StartsWith(*text, "ftp.", base::CompareCase::INSENSITIVE_ASCII)
440 ? url::kFtpScheme 446 ? url::kFtpScheme
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 } 675 }
670 676
671 bool IsEquivalentScheme(const std::string& scheme1, 677 bool IsEquivalentScheme(const std::string& scheme1,
672 const std::string& scheme2) { 678 const std::string& scheme2) {
673 return scheme1 == scheme2 || 679 return scheme1 == scheme2 ||
674 (scheme1 == url::kAboutScheme && scheme2 == kChromeUIScheme) || 680 (scheme1 == url::kAboutScheme && scheme2 == kChromeUIScheme) ||
675 (scheme1 == kChromeUIScheme && scheme2 == url::kAboutScheme); 681 (scheme1 == kChromeUIScheme && scheme2 == url::kAboutScheme);
676 } 682 }
677 683
678 } // namespace url_formatter 684 } // namespace url_formatter
OLDNEW
« 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