Repository: microsoft/PowerToys
File: src/modules/launcher/Wox.Plugin/Common/DefaultBrowserInfo.cs (C#)

Code before:

                    Name = appName;

                    string commandPattern = GetRegistryValue($@"HKEY_CLASSES_ROOT\{progId}\shell\open\command", null);

                    if (string.IsNullOrEmpty(commandPattern))
                    {
                        throw new ArgumentOutOfRangeException(
                            nameof(commandPattern),
                            "Default browser program command is not specified.");
                    }

                    if (commandPattern.StartsWith('@'))
                    {
                        commandPattern = GetIndirectString(commandPattern);
                    }

                    // workaround for firefox installed through Microsoft store
                    const string FirefoxExecutableName = "firefox.exe";
                    if (commandPattern.Contains(FirefoxExecutableName) && commandPattern.Contains(@"C:\Program Files\WindowsApps\") && (!commandPattern.StartsWith('\"')))
                    {
                        var pathEndIndex = commandPattern.IndexOf(FirefoxExecutableName, StringComparison.Ordinal) + FirefoxExecutableName.Length + 1;
                        commandPattern = commandPattern.Insert(0, "\"");
                        commandPattern = commandPattern.Insert(pathEndIndex, "\"");
                    }

                    if (commandPattern.StartsWith('\"'))
                    {
                        var endQuoteIndex = commandPattern.IndexOf('\"', 1);
                        if (endQuoteIndex != -1)
                        {
                            Path = commandPattern.Substring(1, endQuoteIndex - 1);
                            ArgumentsPattern = commandPattern.Substring(endQuoteIndex + 1).Trim();
                        }
                    }
                    else
                    {
                        var spaceIndex = commandPattern.IndexOf(' ');
                        if (spaceIndex != -1)
                        {
                            Path = commandPattern.Substring(0, spaceIndex);
                            ArgumentsPattern = commandPattern.Substring(spaceIndex + 1).Trim();
                        }
                    }

                    if (string.IsNullOrEmpty(Path))
                    {
                        throw new ArgumentOutOfRangeException(
                            nameof(Path),
                            "Default browser program path could not be determined.");
                    }

Review comment (bug):
Have you tested this? Doesn't the first insert make it so that the following insert adds the `"` in the wrong place, since you've changed it already?

Code after:

                    Name = appName;

                    string commandPattern = GetRegistryValue($@"HKEY_CLASSES_ROOT\{progId}\shell\open\command", null);

                    if (string.IsNullOrEmpty(commandPattern))
                    {
                        throw new ArgumentOutOfRangeException(
                            nameof(commandPattern),
                            "Default browser program command is not specified.");
                    }

                    if (commandPattern.StartsWith('@'))
                    {
                        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);
                        if (endQuoteIndex != -1)
                        {
                            Path = commandPattern.Substring(1, endQuoteIndex - 1);
                            ArgumentsPattern = commandPattern.Substring(endQuoteIndex + 1).Trim();
                        }
                    }
                    else
                    {
                        var spaceIndex = commandPattern.IndexOf(' ');
                        if (spaceIndex != -1)
                        {
                            Path = commandPattern.Substring(0, spaceIndex);
                            ArgumentsPattern = commandPattern.Substring(spaceIndex + 1).Trim();
                        }
                    }

                    if (string.IsNullOrEmpty(Path))
                    {
                        throw new ArgumentOutOfRangeException(