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

Side by Side Diff: net/base/net_util_unittest.cc

Issue 23464037: Net: make IsSafePortableRelativePath look for reserved names on all components. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« net/base/net_util.h ('K') | « net/base/net_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "net/base/net_util.h" 5 #include "net/base/net_util.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 3440 matching lines...) Expand 10 before | Expand all | Expand 10 after
3451 #endif 3451 #endif
3452 }; 3452 };
3453 3453
3454 static const base::FilePath::CharType* kSafePortableRelativePaths[] = { 3454 static const base::FilePath::CharType* kSafePortableRelativePaths[] = {
3455 FILE_PATH_LITERAL("a/a"), 3455 FILE_PATH_LITERAL("a/a"),
3456 #if defined(OS_WIN) 3456 #if defined(OS_WIN)
3457 FILE_PATH_LITERAL("a\\a"), 3457 FILE_PATH_LITERAL("a\\a"),
3458 #endif 3458 #endif
3459 }; 3459 };
3460 3460
3461 TEST(NetUtilTest, IsSafePortableBasename) { 3461 TEST(NetUtilTest, IsSafePortablePathComponent) {
3462 for (size_t i = 0 ; i < arraysize(kSafePortableBasenames); ++i) { 3462 for (size_t i = 0 ; i < arraysize(kSafePortableBasenames); ++i) {
3463 EXPECT_TRUE(IsSafePortableBasename(base::FilePath( 3463 EXPECT_TRUE(IsSafePortablePathComponent(base::FilePath(
3464 kSafePortableBasenames[i]))) << kSafePortableBasenames[i]; 3464 kSafePortableBasenames[i]))) << kSafePortableBasenames[i];
3465 } 3465 }
3466 for (size_t i = 0 ; i < arraysize(kUnsafePortableBasenames); ++i) { 3466 for (size_t i = 0 ; i < arraysize(kUnsafePortableBasenames); ++i) {
3467 EXPECT_FALSE(IsSafePortableBasename(base::FilePath( 3467 EXPECT_FALSE(IsSafePortablePathComponent(base::FilePath(
3468 kUnsafePortableBasenames[i]))) << kUnsafePortableBasenames[i]; 3468 kUnsafePortableBasenames[i]))) << kUnsafePortableBasenames[i];
3469 } 3469 }
3470 for (size_t i = 0 ; i < arraysize(kSafePortableRelativePaths); ++i) { 3470 for (size_t i = 0 ; i < arraysize(kSafePortableRelativePaths); ++i) {
3471 EXPECT_FALSE(IsSafePortableBasename(base::FilePath( 3471 EXPECT_FALSE(IsSafePortablePathComponent(base::FilePath(
3472 kSafePortableRelativePaths[i]))) << kSafePortableRelativePaths[i]; 3472 kSafePortableRelativePaths[i]))) << kSafePortableRelativePaths[i];
3473 } 3473 }
3474 } 3474 }
3475 3475
3476 TEST(NetUtilTest, IsSafePortableRelativePath) { 3476 TEST(NetUtilTest, IsSafePortableRelativePath) {
3477 base::FilePath safe_dirname(FILE_PATH_LITERAL("a")); 3477 base::FilePath safe_dirname(FILE_PATH_LITERAL("a"));
3478 for (size_t i = 0 ; i < arraysize(kSafePortableBasenames); ++i) { 3478 for (size_t i = 0 ; i < arraysize(kSafePortableBasenames); ++i) {
3479 EXPECT_TRUE(IsSafePortableRelativePath(base::FilePath( 3479 EXPECT_TRUE(IsSafePortableRelativePath(base::FilePath(
3480 kSafePortableBasenames[i]))) << kSafePortableBasenames[i]; 3480 kSafePortableBasenames[i]))) << kSafePortableBasenames[i];
3481 EXPECT_TRUE(IsSafePortableRelativePath(safe_dirname.Append(base::FilePath( 3481 EXPECT_TRUE(IsSafePortableRelativePath(safe_dirname.Append(base::FilePath(
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
3572 TEST_P(NetUtilNonUniqueNameTest, IsHostnameNonUnique) { 3572 TEST_P(NetUtilNonUniqueNameTest, IsHostnameNonUnique) {
3573 const NonUniqueNameTestData& test_data = GetParam(); 3573 const NonUniqueNameTestData& test_data = GetParam();
3574 3574
3575 EXPECT_EQ(test_data.is_unique, IsUnique(test_data.hostname)); 3575 EXPECT_EQ(test_data.is_unique, IsUnique(test_data.hostname));
3576 } 3576 }
3577 3577
3578 INSTANTIATE_TEST_CASE_P(, NetUtilNonUniqueNameTest, 3578 INSTANTIATE_TEST_CASE_P(, NetUtilNonUniqueNameTest,
3579 testing::ValuesIn(kNonUniqueNameTestData)); 3579 testing::ValuesIn(kNonUniqueNameTestData));
3580 3580
3581 } // namespace net 3581 } // namespace net
OLDNEW
« net/base/net_util.h ('K') | « net/base/net_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698