OLD | NEW |
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 "net/base/net_util.h" | 5 #include "net/base/net_util.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 spec.begin() + parsed.CountCharactersBefore(url::Parsed::USERNAME, true)); | 697 spec.begin() + parsed.CountCharactersBefore(url::Parsed::USERNAME, true)); |
698 const char kHTTP[] = "http://"; | 698 const char kHTTP[] = "http://"; |
699 const char kFTP[] = "ftp."; | 699 const char kFTP[] = "ftp."; |
700 // url_fixer::FixupURL() treats "ftp.foo.com" as ftp://ftp.foo.com. This | 700 // url_fixer::FixupURL() treats "ftp.foo.com" as ftp://ftp.foo.com. This |
701 // means that if we trim "http://" off a URL whose host starts with "ftp." and | 701 // means that if we trim "http://" off a URL whose host starts with "ftp." and |
702 // the user inputs this into any field subject to fixup (which is basically | 702 // the user inputs this into any field subject to fixup (which is basically |
703 // all input fields), the meaning would be changed. (In fact, often the | 703 // all input fields), the meaning would be changed. (In fact, often the |
704 // formatted URL is directly pre-filled into an input field.) For this reason | 704 // formatted URL is directly pre-filled into an input field.) For this reason |
705 // we avoid stripping "http://" in this case. | 705 // we avoid stripping "http://" in this case. |
706 bool omit_http = (format_types & kFormatUrlOmitHTTP) && | 706 bool omit_http = (format_types & kFormatUrlOmitHTTP) && |
707 EqualsASCII(url_string, kHTTP) && | 707 base::EqualsASCII(url_string, kHTTP) && |
708 !StartsWithASCII(url.host(), kFTP, true); | 708 !StartsWithASCII(url.host(), kFTP, true); |
709 new_parsed->scheme = parsed.scheme; | 709 new_parsed->scheme = parsed.scheme; |
710 | 710 |
711 // Username & password. | 711 // Username & password. |
712 if ((format_types & kFormatUrlOmitUsernamePassword) != 0) { | 712 if ((format_types & kFormatUrlOmitUsernamePassword) != 0) { |
713 // Remove the username and password fields. We don't want to display those | 713 // Remove the username and password fields. We don't want to display those |
714 // to the user since they can be used for attacks, | 714 // to the user since they can be used for attacks, |
715 // e.g. "http://google.com:search@evil.ru/" | 715 // e.g. "http://google.com:search@evil.ru/" |
716 new_parsed->username.reset(); | 716 new_parsed->username.reset(); |
717 new_parsed->password.reset(); | 717 new_parsed->password.reset(); |
718 // Update the adjustments based on removed username and/or password. | 718 // Update the adjustments based on removed username and/or password. |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 if (offset_for_adjustment) | 826 if (offset_for_adjustment) |
827 offsets.push_back(*offset_for_adjustment); | 827 offsets.push_back(*offset_for_adjustment); |
828 base::string16 result = FormatUrlWithOffsets(url, languages, format_types, | 828 base::string16 result = FormatUrlWithOffsets(url, languages, format_types, |
829 unescape_rules, new_parsed, prefix_end, &offsets); | 829 unescape_rules, new_parsed, prefix_end, &offsets); |
830 if (offset_for_adjustment) | 830 if (offset_for_adjustment) |
831 *offset_for_adjustment = offsets[0]; | 831 *offset_for_adjustment = offsets[0]; |
832 return result; | 832 return result; |
833 } | 833 } |
834 | 834 |
835 } // namespace net | 835 } // namespace net |
OLD | NEW |