[PR #12342] [CLOSED] Don't crash when reading emoji input in utf8 #28993

Open
opened 2026-01-31 09:32:08 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/12342
Author: @zadjii-msft
Created: 2/3/2022
Status: Closed

Base: mainHead: dev/migrie/b/8663-input-to-oem-crash


📝 Commits (7)

  • 522c373 this doesn't crash but I bet it breaks something. It's also not particularly clever
  • e687d17 Comments. I believe I'm okay here.
  • 7ac2d6d I think this is a valid test for #8663
  • b11c18e spel, more comment
  • 956e251 sneaky typo
  • 34c921f fircken unsigned
  • 3f6d678 Migrate spelling-0.0.21 changes from main

📊 Changes

19 files changed (+1206 additions, -851 deletions)

View changed files

.github/actions/spelling/README.md (+15 -0)
📝 .github/actions/spelling/advice.md (+16 -18)
📝 .github/actions/spelling/allow/allow.txt (+22 -6)
📝 .github/actions/spelling/allow/apis.txt (+31 -7)
📝 .github/actions/spelling/allow/microsoft.txt (+7 -1)
📝 .github/actions/spelling/allow/names.txt (+8 -0)
.github/actions/spelling/candidate.patterns (+523 -0)
📝 .github/actions/spelling/excludes.txt (+41 -5)
📝 .github/actions/spelling/expect/alphabet.txt (+0 -8)
📝 .github/actions/spelling/expect/expect.txt (+153 -735)
📝 .github/actions/spelling/expect/web.txt (+0 -23)
.github/actions/spelling/line_forbidden.patterns (+62 -0)
📝 .github/actions/spelling/patterns/patterns.txt (+74 -8)
📝 .github/actions/spelling/reject.txt (+9 -19)
📝 .github/workflows/spelling2.yml (+123 -9)
📝 src/host/directio.cpp (+10 -0)
📝 src/host/inputBuffer.cpp (+35 -11)
📝 src/host/readDataDirect.cpp (+9 -0)
📝 src/host/ut_host/InputBufferTests.cpp (+68 -1)

📄 Description

Summary of the Pull Request

In the two places we read input from the console input buffer, we were not accounting for the fact that unicode input might turn into more than two input records.

InputBuffer::Read tries to account for how big unicode characters will be when read as input events, and only returns as much input as will fit in the caller's buffer. However, we were using IsGlyphFullWidth to check if a glyph was wide. However, that's not always right. SplitToOem might make three chars out of a single key, like in the case of emoji in utf8.

PR Checklist

Validation Steps Performed


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/12342 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 2/3/2022 **Status:** ❌ Closed **Base:** `main` ← **Head:** `dev/migrie/b/8663-input-to-oem-crash` --- ### 📝 Commits (7) - [`522c373`](https://github.com/microsoft/terminal/commit/522c373421d59f7924420bb36233bbb7726d17fa) this doesn't crash but I bet it breaks something. It's also not particularly clever - [`e687d17`](https://github.com/microsoft/terminal/commit/e687d17a406daa533180cb7c506877ea1af1495f) Comments. I believe I'm okay here. - [`7ac2d6d`](https://github.com/microsoft/terminal/commit/7ac2d6d9719ef5715a27f39121bb1ca69eb337e4) I think this is a valid test for #8663 - [`b11c18e`](https://github.com/microsoft/terminal/commit/b11c18ecebf59c4163d93871f817df1ca94af3d1) spel, more comment - [`956e251`](https://github.com/microsoft/terminal/commit/956e251eb94b8c2303eef745edfd7c0bb8bc686c) sneaky typo - [`34c921f`](https://github.com/microsoft/terminal/commit/34c921f8663a93ced1499616b0e4b72fc016aad4) fircken unsigned - [`3f6d678`](https://github.com/microsoft/terminal/commit/3f6d678b7c1ac7d043c9e86f8d5fbba2bb275e64) Migrate spelling-0.0.21 changes from main ### 📊 Changes **19 files changed** (+1206 additions, -851 deletions) <details> <summary>View changed files</summary> ➕ `.github/actions/spelling/README.md` (+15 -0) 📝 `.github/actions/spelling/advice.md` (+16 -18) 📝 `.github/actions/spelling/allow/allow.txt` (+22 -6) 📝 `.github/actions/spelling/allow/apis.txt` (+31 -7) 📝 `.github/actions/spelling/allow/microsoft.txt` (+7 -1) 📝 `.github/actions/spelling/allow/names.txt` (+8 -0) ➕ `.github/actions/spelling/candidate.patterns` (+523 -0) 📝 `.github/actions/spelling/excludes.txt` (+41 -5) 📝 `.github/actions/spelling/expect/alphabet.txt` (+0 -8) 📝 `.github/actions/spelling/expect/expect.txt` (+153 -735) 📝 `.github/actions/spelling/expect/web.txt` (+0 -23) ➕ `.github/actions/spelling/line_forbidden.patterns` (+62 -0) 📝 `.github/actions/spelling/patterns/patterns.txt` (+74 -8) 📝 `.github/actions/spelling/reject.txt` (+9 -19) 📝 `.github/workflows/spelling2.yml` (+123 -9) 📝 `src/host/directio.cpp` (+10 -0) 📝 `src/host/inputBuffer.cpp` (+35 -11) 📝 `src/host/readDataDirect.cpp` (+9 -0) 📝 `src/host/ut_host/InputBufferTests.cpp` (+68 -1) </details> ### 📄 Description ## Summary of the Pull Request In the two places we read input from the console input buffer, we were not accounting for the fact that unicode input might turn into more than two input records. `InputBuffer::Read` tries to account for how big unicode characters will be when read as input events, and only returns as much input as _will_ fit in the caller's buffer. However, we were using `IsGlyphFullWidth` to check if a glyph was wide. However, that's not always right. `SplitToOem` might make three `char`s out of a single key, like in the case of emoji in utf8. ## PR Checklist * [x] Closes #8663 * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated ## Validation Steps Performed * wrote tests * Confirmed that the sample in https://github.com/microsoft/terminal/issues/8663#issuecomment-904788661 no longer crashes --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:32:08 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#28993