From 7ae448f0b1a27923722c4e05926fae79f5d69699 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 8 Jul 2016 16:17:32 -0700 Subject: [PATCH] Blacklist control characters rather than whitelist --- .../host/msh/ConsoleHostUserInterface.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs index 83581f061..146855863 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs @@ -399,10 +399,9 @@ namespace Microsoft.PowerShell } } #if LINUX - else if (!(Char.IsLetterOrDigit(k) || Char.IsPunctuation(k) || Char.IsSymbol(k) || Char.IsWhiteSpace(k))) + else if (Char.IsControl(k)) { - // Whitelist valid input characters: letters, digits, punctuation, symbols whitespace - // This is to avoid edge cases like Pause, Print Screen, function keys, and Oem keys, etc. + // blacklist control characters continue; } #endif @@ -1941,10 +1940,9 @@ namespace Microsoft.PowerShell } char k = keyInfo.KeyChar; - if (!(Char.IsLetterOrDigit(k) || Char.IsPunctuation(k) || Char.IsSymbol(k) || Char.IsWhiteSpace(k))) + else if (Char.IsControl(k)) { - // Whitelist valid input characters: letters, digits, punctuation, symbols whitespace - // This is to avoid edge cases like Pause, Print Screen, function keys, and Oem keys, etc. + // blacklist control characters continue; }