From 4a8e3624e4c113de91a68f65afdc6f924e384d13 Mon Sep 17 00:00:00 2001 From: sosssego Date: Wed, 21 Sep 2022 14:31:45 +0100 Subject: [PATCH] [PTRun]Fix for Firefox search when installed from the store (#20350) Hack to fix command path for firefox installed through Microsoft Store --- .../launcher/Wox.Plugin/Common/DefaultBrowserInfo.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/modules/launcher/Wox.Plugin/Common/DefaultBrowserInfo.cs b/src/modules/launcher/Wox.Plugin/Common/DefaultBrowserInfo.cs index 52d1563877..0d1ea0b15e 100644 --- a/src/modules/launcher/Wox.Plugin/Common/DefaultBrowserInfo.cs +++ b/src/modules/launcher/Wox.Plugin/Common/DefaultBrowserInfo.cs @@ -114,6 +114,18 @@ namespace Wox.Plugin.Common commandPattern = GetIndirectString(commandPattern); } + // HACK: for firefox installed through Microsoft store + // When installed through Microsoft Firefox the commandPattern does not have + // quotes for the path. As the Program Files does have a space + // the extracted path would be invalid, here we add the quotes to fix it + const string FirefoxExecutableName = "firefox.exe"; + if (commandPattern.Contains(FirefoxExecutableName) && commandPattern.Contains(@"\WindowsApps\") && (!commandPattern.StartsWith('\"'))) + { + var pathEndIndex = commandPattern.IndexOf(FirefoxExecutableName, StringComparison.Ordinal) + FirefoxExecutableName.Length; + commandPattern = commandPattern.Insert(pathEndIndex, "\""); + commandPattern = commandPattern.Insert(0, "\""); + } + if (commandPattern.StartsWith('\"')) { var endQuoteIndex = commandPattern.IndexOf('\"', 1);