summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjschuh@chromium.org <jschuh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-30 14:49:41 +0000
committerjschuh@chromium.org <jschuh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-30 14:49:41 +0000
commit790613cb3725005dda8f7fbfaa344a9e99a8f2a8 (patch)
treeae12eb3387f2071762bc6f8e606c587b1b2a7c03 /chrome
parent7ba0e1a08c29d56302158767dc6526ce798ce762 (diff)
downloadchromium_src-790613cb3725005dda8f7fbfaa344a9e99a8f2a8.zip
chromium_src-790613cb3725005dda8f7fbfaa344a9e99a8f2a8.tar.gz
chromium_src-790613cb3725005dda8f7fbfaa344a9e99a8f2a8.tar.bz2
Replaces the % character with \x when generating Windows shortcuts via
File->"Create application shortcuts." The \x is converted back to % in handling the --app switch. BUG=23693 TEST=None Review URL: http://codereview.chromium.org/515028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35377 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser_init.cc7
-rw-r--r--chrome/browser/shell_integration_unittest.cc12
-rw-r--r--chrome/common/chrome_plugin_util.cc11
3 files changed, 19 insertions, 11 deletions
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index 568d0fd..07addd7 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -492,7 +492,12 @@ bool BrowserInit::LaunchWithProfile::OpenApplicationURL(Profile* profile) {
if (!command_line_.HasSwitch(switches::kApp))
return false;
- GURL url(command_line_.GetSwitchValueASCII(switches::kApp));
+ std::string url_string(command_line_.GetSwitchValueASCII(switches::kApp));
+#if defined(OS_WIN) // Fix up Windows shortcuts.
+ ReplaceSubstringsAfterOffset(&url_string, 0, "\\x", "%");
+#endif
+ GURL url(url_string);
+
if (!url.is_empty() && url.is_valid()) {
Browser::OpenApplicationWindow(profile, url);
return true;
diff --git a/chrome/browser/shell_integration_unittest.cc b/chrome/browser/shell_integration_unittest.cc
index 6352d5a..7133031 100644
--- a/chrome/browser/shell_integration_unittest.cc
+++ b/chrome/browser/shell_integration_unittest.cc
@@ -132,7 +132,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",
@@ -144,10 +144,10 @@ TEST(ShellIntegrationTest, GetDesktopFileContents) {
"#!/usr/bin/env xdg-open\n"
"Name=Innocent Title\n"
"Exec=/opt/google/chrome/google-chrome "
- "--app=\"http://evil.com/evil%%20rm%%20-rf%%20/%%20%%22%%20rm%%20"
- "-rf%%20HOME%%20%%3Eownz0red\"\n"
+ "--app=\"http://evil.com/evil%3B%20rm%20-rf%20/%3B%20%22%3B%20rm%20"
+ "-rf%20%24HOME%20%3Eownz0red\"\n"
},
- { "http://evil.com/evil | cat `echo ownz0red` >/dev/null\\",
+ { "http://evil.com/evil | cat `echo ownz0red` >/dev/null",
"Innocent Title",
"chrome-http__evil.com_evil",
@@ -157,8 +157,8 @@ 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++) {
diff --git a/chrome/common/chrome_plugin_util.cc b/chrome/common/chrome_plugin_util.cc
index e3b0f40..128fe1b 100644
--- a/chrome/common/chrome_plugin_util.cc
+++ b/chrome/common/chrome_plugin_util.cc
@@ -150,10 +150,13 @@ CPError CPB_GetCommandLineArgumentsCommon(const char* url,
// chrome.
// Note: Do not change this flag! Old Gears shortcuts will break if you do!
std::string url_string(url);
- ReplaceSubstringsAfterOffset(&url_string, 0, "\"", "\\\"");
- ReplaceSubstringsAfterOffset(&url_string, 0, "%", "%%");
- ReplaceSubstringsAfterOffset(&url_string, 0, ";", "");
- ReplaceSubstringsAfterOffset(&url_string, 0, "$", "");
+ ReplaceSubstringsAfterOffset(&url_string, 0, "\\", "%5C");
+ ReplaceSubstringsAfterOffset(&url_string, 0, "\"", "%22");
+ ReplaceSubstringsAfterOffset(&url_string, 0, ";", "%3B");
+ ReplaceSubstringsAfterOffset(&url_string, 0, "$", "%24");
+#if defined(OS_WIN) // Windows shortcuts can't escape % so we use \x instead.
+ ReplaceSubstringsAfterOffset(&url_string, 0, "%", "\\x");
+#endif
std::wstring url_w = UTF8ToWide(url_string);
// TODO(evanm): use CommandLine APIs instead of this.
arguments_w += std::wstring(L"--") + ASCIIToWide(switches::kApp) +