Do not let a hand edited key name take the tray down - #818
Merged
Conversation
KeyRegister parsed the key half of a hot key with Enum.Parse<Keys>, unguarded, and SettingsValidator only checked that it was non-empty. So "Key": "Ctrl+A" in settings.json passed the "Cannot start" guard, which only covers reading the file, and then threw ArgumentException out of ReBindKeys during startup - at every login, until the file was deleted by hand. Enum.Parse also reads the underlying number, so "Key": "1" silently bound the left mouse button rather than the digit. KeyName.TryParse is the one reader now. It rejects numbers and flag lists before parsing and accepts aliases, which is why it is not a round trip through ToString: Keys gives several values two names and prints the other one, so "Enter" would have been rejected. A key it cannot read leaves that hot key unbound and the tray running, and the tray says so with a balloon tip rather than only a log line - the same message covers a key already registered by another application, which was silent before. The Options form cannot produce either, offering nothing but letters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
KeyRegister parsed the key half of a hot key with Enum.Parse, unguarded, and
SettingsValidator only checked that it was non-empty. So "Key": "Ctrl+A" in
settings.json passed the "Cannot start" guard, which only covers reading the file,
and then threw ArgumentException out of ReBindKeys during startup - at every login,
until the file was deleted by hand.
Enum.Parse also reads the underlying number, so "Key": "1" silently bound the left
mouse button rather than the digit.
KeyName.TryParse is the one reader now. It rejects numbers and flag lists before
parsing and accepts aliases, which is why it is not a round trip through ToString:
Keys gives several values two names and prints the other one, so "Enter" would have
been rejected. A key it cannot read leaves that hot key unbound and the tray running,
and the tray says so with a balloon tip rather than only a log line - the same
message covers a key already registered by another application, which was silent
before. The Options form cannot produce either, offering nothing but letters.