Format URLs for display when we show the tooltip (#15095)

This will reduce the incidence of confusables, RTL, and non-printables
messing with the display of the URL.

(cherry picked from commit 06174a9cb3)
Service-Card-Id: 88740699
Service-Version: 1.17
This commit is contained in:
Dustin L. Howett 2023-04-03 16:22:25 -05:00 committed by Dustin Howett
parent 30419b99df
commit 87333f79ed
2 changed files with 14 additions and 1 deletions

View File

@ -257,6 +257,7 @@ condrv
conechokey
conemu
configurability
confusables
conhost
conime
conimeinfo

View File

@ -2891,7 +2891,19 @@ namespace winrt::Microsoft::Terminal::Control::implementation
auto lastHoveredCell = _core.HoveredCell();
if (lastHoveredCell)
{
const auto uriText = _core.HoveredUriText();
winrt::hstring uriText = _core.HoveredUriText();
try
{
// DisplayUri will filter out non-printable characters and confusables.
Windows::Foundation::Uri parsedUri{ uriText };
uriText = parsedUri.DisplayUri();
}
catch (...)
{
LOG_CAUGHT_EXCEPTION();
uriText = {};
}
if (!uriText.empty())
{
const auto panel = SwapChainPanel();