dpwas: Escape % in Linux app shortcut launch URLs

This CL escapes % in Linux shortcut launch URLs as %%. Other special
characters mentioned on this page are tested to work fine:
https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s07.html

How to test:
1. Install https://mandymsft.github.io/pwa on Linux (I used Ubuntu)
2. Right click or bring up the shortcuts menu otherwise, and click on
each one to see if successful

Bug: 1283742
Change-Id: I5a92963f471b2a65a6f843c9ea8a32ca6b6dc319
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3381315
Reviewed-by: Thomas Anderson <[email protected]>
Commit-Queue: Mandy Chen <[email protected]>
Cr-Commit-Position: refs/heads/main@{#957835}
diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc
index 2d53c36..fead1b1 100644
--- a/chrome/browser/shell_integration_linux.cc
+++ b/chrome/browser/shell_integration_linux.cc
@@ -54,6 +54,7 @@
 #include "chrome/grit/chrome_unscaled_resources.h"
 #include "components/version_info/version_info.h"
 #include "third_party/libxml/chromium/xml_writer.h"
+#include "third_party/re2/src/re2/re2.h"
 #include "ui/base/resource/resource_bundle.h"
 #include "ui/gfx/image/image_family.h"
 #include "ui/ozone/public/ozone_platform.h"
@@ -280,9 +281,12 @@
     g_key_file_set_string(key_file, section_title.c_str(), "Name",
                           info.name.c_str());
 
+    std::string launch_url_str = info.exec_launch_url.spec();
+    // Escape % as %%.
+    RE2::GlobalReplace(&launch_url_str, "%", "%%");
     base::CommandLine current_cmd(command_line);
     current_cmd.AppendSwitchASCII(switches::kAppLaunchUrlForShortcutsMenuItem,
-                                  info.exec_launch_url.spec());
+                                  launch_url_str);
 
     g_key_file_set_string(
         key_file, section_title.c_str(), "Exec",