Skip to content

Commit

Permalink
Fix a crash in the GenerateName for SearchForTextArgs (#16054)
Browse files Browse the repository at this point in the history
Fixes MSFT:46725264

don't explode trying to parse a URL, if the string wasn't one.

(cherry picked from commit 59aaba7)
Service-Card-Id: 90687770
Service-Version: 1.19
  • Loading branch information
zadjii-msft authored and DHowett committed Oct 3, 2023
1 parent 70ad670 commit 4ee21b3
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/cascadia/TerminalSettingsModel/ActionArgs.cpp
Expand Up @@ -814,10 +814,25 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation

winrt::hstring SearchForTextArgs::GenerateName() const
{
return winrt::hstring{
fmt::format(std::wstring_view(RS_(L"SearchForTextCommandKey")),
Windows::Foundation::Uri(QueryUrl()).Domain().c_str())
};
if (QueryUrl().empty())
{
// Return the default command name, because we'll just use the
// default search engine for this.
return RS_(L"SearchWebCommandKey");
}

try
{
return winrt::hstring{
fmt::format(std::wstring_view(RS_(L"SearchForTextCommandKey")),
Windows::Foundation::Uri(QueryUrl()).Domain().c_str())
};
}
CATCH_LOG();

// We couldn't parse a URL out of this. Return no string at all, so that
// we don't even put this into the command palette.
return L"";
}

winrt::hstring GlobalSummonArgs::GenerateName() const
Expand Down

0 comments on commit 4ee21b3

Please sign in to comment.