-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display Unicode URIs side-by-side with their Punycode encoding #15488
Display Unicode URIs side-by-side with their Punycode encoding #15488
Conversation
@@ -3042,56 +3042,85 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |||
_core.ClearHoveredCell(); | |||
} | |||
|
|||
winrt::fire_and_forget TermControl::_hoveredHyperlinkChanged(IInspectable /*sender*/, | |||
IInspectable /*args*/) | |||
// Attackers abuse Unicode characters that happen to look similar to ASCII characters. Cyrillic for instance has |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
const auto uriText = sanitizeURI(_core.HoveredUriText()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we should encode URIs to Punycode a little earlier than this... If the encoding to Punycode fails, we shouldn't even allow the option to click it. On the other hand, the old code didn't handle that either and this fixes the immediate issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, I am OKAY with this.
Thanks so much.
wait can you ctrl+click invalid URIs? |
send a screenshot! |
to be clear, it was not intended to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notes and Qs.
Generally, I am 100% happy with this. Just the UI thread concern!
} | ||
|
||
const auto uriText = sanitizeURI(_core.HoveredUriText()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, I am OKAY with this.
Thanks so much.
{ | ||
auto weakThis{ get_weak() }; | ||
co_await wil::resume_foreground(Dispatcher()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is another instance where we were switching to the foreground to make touching UI objects safe. Are we convinced that this is safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only place _hoveredHyperlinkChanged
is called from is the _core.HoveredHyperlinkChanged()
event. _HoveredHyperlinkChangedHandlers
is only called in ControlCore::_updateHoveredCell
, which in turn is only called by SetHoveredCell
and ClearHoveredCell
. The former is only called by ControlInteractivity::PointerMoved
which is a UI-thread-only function and the latter is only called by TermControl::_PointerExitedHandler
which is the same. BTW It's somewhat weird that PointerMoved
us in ControlInteractivity
, but "pointer exited" isn't.
So yeah this can only be called from the UI thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's technically an implementation detail, but I'll allow it ;P
@@ -178,6 +178,10 @@ | |||
<data name="HowToOpenRun.Text" xml:space="preserve"> | |||
<value>Ctrl+Click to follow link</value> | |||
</data> | |||
<data name="InvalidUri" xml:space="preserve"> | |||
<value>Invalid URI</value> | |||
<comment>Whenever we encounter an invalid URI or URL we show this string as a warning.</comment> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<comment>Whenever we encounter an invalid URI or URL we show this string as a warning.</comment> | |
<comment>Whenever we encounter an invalid URI or URL we show this string as an error.</comment> |
nit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I feel like "as a warning" is better in this case. 🤔
After all, this doesn't prevent you from clicking the URL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am okay merging without fixing Carlos' comments honestly
Co-authored-by: Carlos Zamora <[email protected]>
06174a9 didn't properly fix the issue of us showing homoglyphs in our URI tooltip. This commit introduces a different approach where we display both, the Punycode and Unicode encoding, whenever we encounter an IDN. This isn't perfect but simple to implement. Closes #15432 ## Validation Steps Performed * `https://www.xn--fcbook-3nf5b.com/` (which contains confusing glyphs) is shown both in its Punycode and Unicode form simultaneously. ✅ --------- Co-authored-by: Carlos Zamora <[email protected]> (cherry picked from commit f1aa699) Service-Card-Id: 90012448 Service-Version: 1.17
06174a9 didn't properly fix the issue of us showing homoglyphs in our URI tooltip. This commit introduces a different approach where we display both, the Punycode and Unicode encoding, whenever we encounter an IDN. This isn't perfect but simple to implement. Closes #15432 ## Validation Steps Performed * `https://www.xn--fcbook-3nf5b.com/` (which contains confusing glyphs) is shown both in its Punycode and Unicode form simultaneously. ✅ --------- Co-authored-by: Carlos Zamora <[email protected]> (cherry picked from commit f1aa699) Service-Card-Id: 90012449 Service-Version: 1.18
06174a9 didn't properly fix the issue of us showing homoglyphs in our
URI tooltip. This commit introduces a different approach where we
display both, the Punycode and Unicode encoding, whenever we encounter
an IDN. This isn't perfect but simple to implement.
Closes #15432
Validation Steps Performed
https://www.xn--fcbook-3nf5b.com/
(which contains confusing glyphs)is shown both in its Punycode and Unicode form simultaneously. ✅