diff options
author | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-06 10:25:35 +0000 |
---|---|---|
committer | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-06 10:25:35 +0000 |
commit | 02c8796f86e238be73fecd15b894724d58a96f4d (patch) | |
tree | 24c98fc21034b55c54d7f907a7977d0680d10322 /base/command_line_unittest.cc | |
parent | 095214d9fd4f7dc5b9218d3fe78cf3ee08f480b8 (diff) | |
download | chromium_src-02c8796f86e238be73fecd15b894724d58a96f4d.zip chromium_src-02c8796f86e238be73fecd15b894724d58a96f4d.tar.gz chromium_src-02c8796f86e238be73fecd15b894724d58a96f4d.tar.bz2 |
Add -- as a command line switch parsing terminator. This allows you to launch chrome to a given URL safely, without having to validate the URL and worry it might be interpreted as a dangerous command line argument.
Review URL: http://codereview.chromium.org/6480
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2876 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/command_line_unittest.cc')
-rw-r--r-- | base/command_line_unittest.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc index f3d63cb..4319b4d 100644 --- a/base/command_line_unittest.cc +++ b/base/command_line_unittest.cc @@ -21,6 +21,7 @@ TEST(CommandLineTest, CommandLineConstructor) { L"--other-switches=\"--dog=canine --cat=feline\" " L"-spaetzle=Crepe -=loosevalue flan " L"--input-translation=\"45\"--output-rotation " + L"-- -- --not-a-switch " L"\"in the time of submarines...\""); #elif defined(OS_POSIX) const char* argv[] = {"program", "--foo=", "-bAr", @@ -28,6 +29,7 @@ TEST(CommandLineTest, CommandLineConstructor) { "--other-switches=--dog=canine --cat=feline", "-spaetzle=Crepe", "-=loosevalue", "flan", "--input-translation=45--output-rotation", + "--", "--", "--not-a-switch", "in the time of submarines..."}; CommandLine cl(arraysize(argv), argv); #endif @@ -38,6 +40,8 @@ TEST(CommandLineTest, CommandLineConstructor) { EXPECT_FALSE(cl.HasSwitch(L"dog")); EXPECT_FALSE(cl.HasSwitch(L"cat")); EXPECT_FALSE(cl.HasSwitch(L"output-rotation")); + EXPECT_FALSE(cl.HasSwitch(L"not-a-switch")); + EXPECT_FALSE(cl.HasSwitch(L"--")); EXPECT_EQ(L"program", cl.program()); @@ -56,13 +60,17 @@ TEST(CommandLineTest, CommandLineConstructor) { EXPECT_EQ(L"--dog=canine --cat=feline", cl.GetSwitchValue(L"other-switches")); EXPECT_EQ(L"45--output-rotation", cl.GetSwitchValue(L"input-translation")); - EXPECT_EQ(3U, cl.GetLooseValueCount()); + EXPECT_EQ(5U, cl.GetLooseValueCount()); CommandLine::LooseValueIterator iter = cl.GetLooseValuesBegin(); EXPECT_EQ(L"flim", *iter); ++iter; EXPECT_EQ(L"flan", *iter); ++iter; + EXPECT_EQ(L"--", *iter); + ++iter; + EXPECT_EQ(L"--not-a-switch", *iter); + ++iter; EXPECT_EQ(L"in the time of submarines...", *iter); ++iter; EXPECT_TRUE(iter == cl.GetLooseValuesEnd()); @@ -116,4 +124,3 @@ TEST(CommandLineTest, AppendSwitches) { EXPECT_EQ(value4.substr(1, value4.length() - 2), cl.GetSwitchValue(switch4)); } #endif - |