Skip to content
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

Fix input corruption for high code points #13667

Merged
1 commit merged into from
Aug 4, 2022

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Aug 4, 2022

We must use 65535 as MAX_PARAMETER_VALUE in order for us to properly parse
win32-input-mode sequences, which transmit UTF-16 characters as parameters.

Closes #12977

Validation Steps Performed

  • Call SendInput with 🙁 (L'\xD83D', L'\xDE41')
  • 🙁 appears on the input line ✅

@ghost ghost added Area-Input Related to input processing (key presses, mouse, etc.) Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal. labels Aug 4, 2022
Comment on lines +24 to +27
// The DEC STD 070 reference recommends supporting up to at least 16384
// for parameter values. 65535 is what XTerm and VTE support.
// GH#12977: We must use 65535 to properly parse win32-input-mode
// sequences, which transmit the UTF-16 character value as a parameter.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] so 32767 should be more than enough.

Ah, the classic famous last words... "should be more than enough". lol
I'm a lot less concerned about this change since we mostly aren't using shorts within the project anymore (for most parts).

@DHowett
Copy link
Member

DHowett commented Aug 4, 2022

@msftbot make sure @j4james signs off

@ghost ghost added the AutoMerge Marked for automatic merge by the bot when requirements are met label Aug 4, 2022
@ghost
Copy link

ghost commented Aug 4, 2022

Hello @DHowett!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I'll only merge this pull request if it's approved by @j4james

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

Copy link
Collaborator

@j4james j4james left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as we don't go above the 65535 mark, I think we're good. I've done a brief scan of the code, and I can't see any obvious risky areas - the code has changed considerably from the days when parameter overflows were a real problem. I've also run a few test sequences with large parameter values to try and trigger a crash, and they all seemed OK (at least in the sense that nothing died).

@ghost ghost merged commit 74cdffe into main Aug 4, 2022
@ghost ghost deleted the dev/lhecker/12977-win32-input-surrogate branch August 4, 2022 22:10
DHowett pushed a commit that referenced this pull request Aug 8, 2022
We must use 65535 as `MAX_PARAMETER_VALUE` in order for us to properly parse
win32-input-mode sequences, which transmit UTF-16 characters as parameters.

Closes #12977

## Validation Steps Performed
* Call `SendInput` with 🙁 (`L'\xD83D'`, `L'\xDE41'`)
* 🙁 appears on the input line ✅

(cherry picked from commit 74cdffe)
Service-Card-Id: 84772549
Service-Version: 1.15
@ghost
Copy link

ghost commented Aug 17, 2022

🎉Windows Terminal v1.14.228 has been released which incorporates this pull request.:tada:

Handy links:

@ghost
Copy link

ghost commented Aug 17, 2022

🎉Windows Terminal Preview v1.15.228 has been released which incorporates this pull request.:tada:

Handy links:

PKRoma pushed a commit to PKRoma/Terminal that referenced this pull request Oct 15, 2022
We must use 65535 as `MAX_PARAMETER_VALUE` in order for us to properly parse
win32-input-mode sequences, which transmit UTF-16 characters as parameters.

Closes microsoft#12977

## Validation Steps Performed
* Call `SendInput` with 🙁 (`L'\xD83D'`, `L'\xDE41'`)
* 🙁 appears on the input line ✅

(cherry picked from commit 74cdffe)
Service-Card-Id: 84772549
Service-Version: 1.15
(cherry picked from commit f3f9eba)
Service-Card-Id: 84772548
Service-Version: 1.14
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Input Related to input processing (key presses, mouse, etc.) Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sending unicode character via KEYEVENTF_UNICODE/VK_PACKET in SendInput outputs the wrong characters
4 participants