diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-08 21:28:14 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-08 21:28:14 +0000 |
commit | b10392939246b06c48eb5debc961839591ebe72a (patch) | |
tree | b120033784ffddc693db30f71025b7eb0c5e26ac /chrome/browser/shell_integration_unittest.cc | |
parent | 8cfb591192035c18087296d931880149b2bf63a6 (diff) | |
download | chromium_src-b10392939246b06c48eb5debc961839591ebe72a.zip chromium_src-b10392939246b06c48eb5debc961839591ebe72a.tar.gz chromium_src-b10392939246b06c48eb5debc961839591ebe72a.tar.bz2 |
Refactor GetCommandLineArgumentsCommon to not use strings.
Passing around command lines as strings is dangerous, because a given
command line is interpretable only with respect to a given parser.
This changes a function to instead pass a CommandLine object for
carrying the arguments around, and relies on the callers to stringify
that as necessary.
It turns out that the Linux desktop file format has a well-defined
syntax that is different than the syntax we were using.
BUG=69467
Review URL: http://codereview.chromium.org/6624072
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77338 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/shell_integration_unittest.cc')
-rw-r--r-- | chrome/browser/shell_integration_unittest.cc | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/chrome/browser/shell_integration_unittest.cc b/chrome/browser/shell_integration_unittest.cc index 9a86b58..1a6b9795 100644 --- a/chrome/browser/shell_integration_unittest.cc +++ b/chrome/browser/shell_integration_unittest.cc @@ -191,7 +191,7 @@ TEST(ShellIntegrationTest, GetDesktopFileContents) { "Version=1.0\n" "Encoding=UTF-8\n" "Name=GMail\n" - "Exec=/opt/google/chrome/google-chrome --app=\"http://gmail.com/\"\n" + "Exec=/opt/google/chrome/google-chrome --app=http://gmail.com/\n" "Terminal=false\n" "Icon=chrome-http__gmail.com\n" "Type=Application\n" @@ -209,7 +209,7 @@ TEST(ShellIntegrationTest, GetDesktopFileContents) { "#!/usr/bin/env xdg-open\n" "Name=GMail\n" - "Exec=/opt/google/chrome/google-chrome --app=\"http://gmail.com/\"\n" + "Exec=/opt/google/chrome/google-chrome --app=http://gmail.com/\n" }, // Make sure i18n-ed comments are removed. @@ -223,7 +223,7 @@ TEST(ShellIntegrationTest, GetDesktopFileContents) { "#!/usr/bin/env xdg-open\n" "Name=GMail\n" - "Exec=/opt/google/chrome/google-chrome --app=\"http://gmail.com/\"\n" + "Exec=/opt/google/chrome/google-chrome --app=http://gmail.com/\n" }, // Make sure that empty icons are replaced by the chrome icon. @@ -238,7 +238,7 @@ TEST(ShellIntegrationTest, GetDesktopFileContents) { "#!/usr/bin/env xdg-open\n" "Name=GMail\n" - "Exec=/opt/google/chrome/google-chrome --app=\"http://gmail.com/\"\n" + "Exec=/opt/google/chrome/google-chrome --app=http://gmail.com/\n" "Icon=/opt/google/chrome/product_logo_48.png\n" }, @@ -253,7 +253,7 @@ TEST(ShellIntegrationTest, GetDesktopFileContents) { "#!/usr/bin/env xdg-open\n" "Name=http://evil.com/evil%20--join-the-b0tnet\n" "Exec=/opt/google/chrome/google-chrome " - "--app=\"http://evil.com/evil%20--join-the-b0tnet\"\n" + "--app=http://evil.com/evil%20--join-the-b0tnet\n" }, { "http://evil.com/evil; rm -rf /; \"; rm -rf $HOME >ownz0red", "Innocent Title", @@ -265,8 +265,11 @@ TEST(ShellIntegrationTest, GetDesktopFileContents) { "#!/usr/bin/env xdg-open\n" "Name=Innocent Title\n" "Exec=/opt/google/chrome/google-chrome " - "--app=\"http://evil.com/evil%3B%20rm%20-rf%20/%3B%20%22%3B%20rm%20" - "-rf%20%24HOME%20%3Eownz0red\"\n" + "\"--app=http://evil.com/evil;%20rm%20-rf%20/;%20%22;%20rm%20" + // Note: $ is escaped as \$ within an arg to Exec, and then + // the \ is escaped as \\ as all strings in a Desktop file should + // be; finally, \\ becomes \\\\ when represented in a C++ string! + "-rf%20\\\\$HOME%20%3Eownz0red\"\n" }, { "http://evil.com/evil | cat `echo ownz0red` >/dev/null", "Innocent Title", @@ -278,11 +281,12 @@ TEST(ShellIntegrationTest, GetDesktopFileContents) { "#!/usr/bin/env xdg-open\n" "Name=Innocent Title\n" "Exec=/opt/google/chrome/google-chrome " - "--app=\"http://evil.com/evil%20%7C%20cat%20%60echo%20ownz0red" - "%60%20%3E/dev/null\"\n" + "--app=http://evil.com/evil%20%7C%20cat%20%60echo%20ownz0red" + "%60%20%3E/dev/null\n" }, }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); i++) { + SCOPED_TRACE(i); EXPECT_EQ(test_cases[i].expected_output, ShellIntegration::GetDesktopFileContents( test_cases[i].template_contents, |