-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Don't crash when reading emoji input in utf8 #12342
Conversation
This comment has been minimized.
This comment has been minimized.
if (virtualReadCount + sizeOfThisKey > readCount) | ||
{ | ||
++virtualReadCount; | ||
break; | ||
} |
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 loop now has two bounds checks instead of one, which might be a bit confusing. We can simplify it by changing the loop to be while (!_storage.empty())
and replacing this if condition with the following:
if (!unicode)
{
...
}
virtualReadCount += sizeOfThisKey;
if (virtualReadCount > readCount)
{
break;
}
if (performNormalRead)
{
...
}
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'd approve this code, but I don't get what virtualReadCount
is supposed to be. The comment for it implies it counts the number of columns ("DBCS records". Right?), which matches the old code, but the new code counts code points. What if the CP is 65001?
Finally the comment for the readCount
parameter implies it counts the number of events, but if that was true we'd only increment virtualReadCount
whenever we push into the outEvents
vector and we don't do that either.
In other words: I don't really get the code. 😅 I can't judge if this code would break anything else in the project. But it's syntactically correct, so... I'd approve it.
The test is now stuck in an infinite loop so something's wrong here. |
Circling back on this PR. Assigning @zadjii-msft since the test is stuck on an infinite loop. |
@check-spelling-bot Report🔴 Please reviewSee the 📂 files view or the 📜action log for details. Unrecognized words (52)
Previously acknowledged words that are now absentaabbcc abbcc ABCDEFGHIJKLMNOPQRSTUVWXY ABORTIFHUNG appcontainer bgra chaof COLORMATRIX CTRLFREQUENCY CTRLVOLUME CUsers dcompile DECARM DECBKM DECCARA DECCRA DECCTR DECERA DECFRA DECPS DECRARA DECRQTSR decrst DECSACE DECSERA DECXCPR DSBCAPS DSBLOCK DSBPLAY DSBUFFERDESC DSBVOLUME dsound DSSCL dxguid ect ENTIREBUFFER eplace Geddy GGI GLOBALFOCUS hicon hrottled icket IGNORELANGUAGE IMPEXP IWIC IXP KOK lpwfx luma NOTIMEOUTIFNOTHUNG nto nugetversions otepad ploc ploca plocm Qaabbcc QUERYOPEN QUZ Qxxxxxxxxxxxxxxx Requiresx sapi SFGAO SFGAOF SFolder SHOWDEFAULT SHOWNA ssa Tdd TOOLWINDOW Tribool umul umulh usp uwa vtapi WAVEFORMATEX wic wincodec windowsterminal wyhash wymix wyr xin xinchaof xinxinchaof XTWINOPS xwwyzz xxyyzz Zabcdefghijklmnopqrstuvwxyz ZYXWVU ZYXWVUTd :arrow_right:To accept ✔️ these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands... in a clone of the git@github.com:microsoft/terminal.git repository curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.21/apply.pl' |
perl - 'https://github.com/microsoft/terminal/actions/runs/3568345734/attempts/1' Errors (1)See the 📂 files view or the 📜action log for details.
See ❌ Event descriptions for more information. ✏️ Contributor please read thisBy default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.
If the listed items are:
See the 🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉 If the flagged items are 🤯 false positivesIf items relate to a ...
|
@zadjii-msft, mind if we close this one in favor of Leonard's rewrite? |
please yes |
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 usingIsGlyphFullWidth
to check if a glyph was wide. However, that's not always right.SplitToOem
might make threechar
s out of a single key, like in the case of emoji in utf8.PR Checklist
Validation Steps Performed