-
Notifications
You must be signed in to change notification settings - Fork 375
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
Sanitize text pasted into hex text boxes #3684
base: master
Are you sure you want to change the base?
Conversation
src/BizHawk.Client.EmuHawk/CustomControls/ClipboardEventTextBox.cs
Outdated
Show resolved
Hide resolved
src/BizHawk.Client.EmuHawk/CustomControls/ClipboardEventTextBox.cs
Outdated
Show resolved
Hide resolved
Does this specifically break any functionality on unix? or just fail to add new functionality? If it is the former, I say we merge this |
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.
adelikat is right, this is better than what we have. Please rebase.
@@ -435,6 +437,21 @@ protected override void OnTextChanged(EventArgs e) | |||
base.OnTextChanged(e); | |||
} | |||
|
|||
protected override void OnPaste(PasteEventArgs e) |
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.
(ditto of everything that applies to other impl.)
int availableLength = MaxLength - TextLength + SelectionLength; | ||
if (text.Length > availableLength) | ||
{ | ||
text = text.Substring(0, availableLength); |
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.
Style nitpicks: Add argument names here, use var
everywhere, use is
for enum/const comparison, use string.Empty
, and make PasteEventArgs
sealed
.
src/BizHawk.Client.EmuHawk/CustomControls/ClipboardEventTextBox.cs
Outdated
Show resolved
Hide resolved
Trim `0x` and `$` prefixes and whitespace pasted into `HexTextBox` and `WatchValueBox`. Prevent pasting non-hex text. Add `ClipboardEventTextBox` control with `OnPaste` event
c494fd8
to
40dce63
Compare
|
Add
ClipboardEventTextBox
control with anOnPaste
method and makeHexTextBox
andWatchValueBox
inherit from thatOverride normal paste behavior to trim
0x
/$
/whitespace from pasted textPrevent pasting of non-hex text
Resolves #3682