diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-07 22:41:58 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-07 22:41:58 +0000 |
commit | 99d28d2f5f6ed613eddd80e29a235498096f41f4 (patch) | |
tree | 6a4942eef8f3985e9c4b9a1835f4129dd5ff17bb /net | |
parent | 4676cf7b5d621619fb7a6ee1a5a9bf5f7e536e7d (diff) | |
download | chromium_src-99d28d2f5f6ed613eddd80e29a235498096f41f4.zip chromium_src-99d28d2f5f6ed613eddd80e29a235498096f41f4.tar.gz chromium_src-99d28d2f5f6ed613eddd80e29a235498096f41f4.tar.bz2 |
Make sure to strip the brackets around IPv6 literals when resolving the hostname for FTP.
BUG=39830 (comment #9)
TEST=FtpNetworkTransactionTest.StripBracketsFromIPv6Literals
Review URL: http://codereview.chromium.org/1585022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43888 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/ftp/ftp_network_transaction.cc | 2 | ||||
-rw-r--r-- | net/ftp/ftp_network_transaction_unittest.cc | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/net/ftp/ftp_network_transaction.cc b/net/ftp/ftp_network_transaction.cc index 651340a..86e19a0 100644 --- a/net/ftp/ftp_network_transaction.cc +++ b/net/ftp/ftp_network_transaction.cc @@ -533,7 +533,7 @@ int FtpNetworkTransaction::DoCtrlResolveHost() { std::string host; int port; - host = request_->url.host(); + host = request_->url.HostNoBrackets(); port = request_->url.EffectiveIntPort(); HostResolver::RequestInfo info(host, port); diff --git a/net/ftp/ftp_network_transaction_unittest.cc b/net/ftp/ftp_network_transaction_unittest.cc index 5ed8add..ded0ad8 100644 --- a/net/ftp/ftp_network_transaction_unittest.cc +++ b/net/ftp/ftp_network_transaction_unittest.cc @@ -677,6 +677,21 @@ TEST_F(FtpNetworkTransactionTest, FailedLookup) { EXPECT_EQ(LOAD_STATE_IDLE, transaction_.GetLoadState()); } +// Check that when determining the host, the square brackets decorating IPv6 +// literals in URLs are stripped. +TEST_F(FtpNetworkTransactionTest, StripBracketsFromIPv6Literals) { + host_resolver_->rules()->AddSimulatedFailure("[::1]"); + + // We start a transaction that is expected to fail with ERR_INVALID_RESPONSE. + // The important part of this test is to make sure that we don't fail with + // ERR_NAME_NOT_RESOLVED, since that would mean the decorated hostname + // was used. + FtpSocketDataProviderEvilSize ctrl_socket( + "213 99999999999999999999999999999999\r\n", + FtpSocketDataProvider::PRE_QUIT); + ExecuteTransaction(&ctrl_socket, "ftp://[::1]/file", ERR_INVALID_RESPONSE); +} + TEST_F(FtpNetworkTransactionTest, DirectoryTransaction) { FtpSocketDataProviderDirectoryListing ctrl_socket; ExecuteTransaction(&ctrl_socket, "ftp://host", OK); |