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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/terminal/parser/stateMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2014,7 +2014,6 @@ void StateMachine::ResetState() noexcept
// into the given size_t. All existing value is moved up by 10.
// - For example, if your value had 437 and you put in the printable number 2,
// this function will update value to 4372.
// - Clamps to 32767 if it gets too big.
// Arguments:
// - wch - Printable character to accumulate into the value (after conversion to number, of course)
// - value - The value to update with the printable character. See example above.
Expand Down
10 changes: 5 additions & 5 deletions src/terminal/parser/stateMachine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ Module Name:

namespace Microsoft::Console::VirtualTerminal
{
// The DEC STD 070 reference recommends supporting up to at least 16384 for
// parameter values, so 32767 should be more than enough. At most we might
// want to increase this to 65535, since that is what XTerm and VTE support,
// but for now 32767 is the safest limit for our existing code base.
constexpr VTInt MAX_PARAMETER_VALUE = 32767;
// 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.
Comment on lines +24 to +27
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).

constexpr VTInt MAX_PARAMETER_VALUE = 65535;

// The DEC STD 070 reference requires that a minimum of 16 parameter values
// are supported, but most modern terminal emulators will allow around twice
Expand Down
2 changes: 1 addition & 1 deletion src/terminal/parser/ut_parser/OutputEngineTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1589,7 +1589,7 @@ class StateMachineExternalTest final
}
else if (uiGiven > MAX_PARAMETER_VALUE)
{
*uiExpected = MAX_PARAMETER_VALUE; // 32767 is our max value.
*uiExpected = MAX_PARAMETER_VALUE;
}
}

Expand Down