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 a ReadConsoleOutputCharacter regression #16898

Merged
merged 4 commits into from
Mar 20, 2024

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Mar 19, 2024

The nLength parameter of ReadConsoleOutputCharacterW indicates
the number of columns that should be read. For single-column (narrow)
surrogate pairs this previously clipped a trailing character of the
returned string. In the major Unicode support update in #13626
surrogate pairs truly got stored as atomic units for the first time.
This now meant that a 120 column read with such codepoints resulted
in 121 characters. Other parts of conhost still assume UCS2 however,
and so this results in the entire read failing.

This fixes the issue by turning surrogate pairs into U+FFFD
which makes it UCS2 compatible.

Closes #16892

Validation Steps Performed

  • Write U+F15C0 and read it back with ReadConsoleOutputCharacterW
  • Read succeeds with a single U+FFFD ✅

@lhecker lhecker force-pushed the dev/lhecker/16892-read-character branch from 5f51d50 to a478a59 Compare March 19, 2024 17:26
Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

Ping me when those TBA are filled in!

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Mar 19, 2024
@DHowett
Copy link
Member

DHowett commented Mar 19, 2024

There's no inbox servicing to be done any longer, unless this is a P0.

@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Mar 19, 2024
@lhecker
Copy link
Member Author

lhecker commented Mar 19, 2024

@DHowett Should be good now. 🙂 I also added a feature test.

This comment has been minimized.

@DHowett DHowett enabled auto-merge (squash) March 20, 2024 18:12
@DHowett DHowett merged commit 373faf0 into main Mar 20, 2024
19 of 20 checks passed
@DHowett DHowett deleted the dev/lhecker/16892-read-character branch March 20, 2024 19:37
DHowett pushed a commit that referenced this pull request Mar 20, 2024
The `nLength` parameter of `ReadConsoleOutputCharacterW` indicates
the number of columns that should be read. For single-column (narrow)
surrogate pairs this previously clipped a trailing character of the
returned string. In the major Unicode support update in #13626
surrogate pairs truly got stored as atomic units for the first time.
This now meant that a 120 column read with such codepoints resulted
in 121 characters. Other parts of conhost still assume UCS2 however,
and so this results in the entire read failing.

This fixes the issue by turning surrogate pairs into U+FFFD
which makes it UCS2 compatible.

Closes #16892

* Write U+F15C0 and read it back with `ReadConsoleOutputCharacterW`
* Read succeeds with a single U+FFFD ✅

(cherry picked from commit 373faf0)
Service-Card-Id: 92121912
Service-Version: 1.20
DHowett pushed a commit that referenced this pull request Mar 20, 2024
The `nLength` parameter of `ReadConsoleOutputCharacterW` indicates
the number of columns that should be read. For single-column (narrow)
surrogate pairs this previously clipped a trailing character of the
returned string. In the major Unicode support update in #13626
surrogate pairs truly got stored as atomic units for the first time.
This now meant that a 120 column read with such codepoints resulted
in 121 characters. Other parts of conhost still assume UCS2 however,
and so this results in the entire read failing.

This fixes the issue by turning surrogate pairs into U+FFFD
which makes it UCS2 compatible.

Closes #16892

* Write U+F15C0 and read it back with `ReadConsoleOutputCharacterW`
* Read succeeds with a single U+FFFD ✅

(cherry picked from commit 373faf0)
Service-Card-Id: 92129542
Service-Version: 1.19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Cherry Picked
3 participants