From e7b9bed8a2128f1bcdf91ece9427580bfe2b2d5d Mon Sep 17 00:00:00 2001 From: avirupch Date: Wed, 25 Mar 2015 14:09:39 +0530 Subject: [PATCH] Fix for Bug 2142619 --- .../NewAzureStorSimpleDeviceVolumeContainer.cs | 2 +- .../StorSimple/Commands.StorSimple/StorSimpleCmdletBase.cs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/DataContainer/NewAzureStorSimpleDeviceVolumeContainer.cs b/src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/DataContainer/NewAzureStorSimpleDeviceVolumeContainer.cs index ad33d1345506..849b79f434d3 100644 --- a/src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/DataContainer/NewAzureStorSimpleDeviceVolumeContainer.cs +++ b/src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/DataContainer/NewAzureStorSimpleDeviceVolumeContainer.cs @@ -65,7 +65,7 @@ public override void ExecuteCmdlet() return; } - if(EncryptionEnabled == true && string.IsNullOrEmpty(EncryptionKey)) + if(EncryptionEnabled == true && (string.IsNullOrEmpty(EncryptionKey) || !IsValidAsciiString(EncryptionKey))) { throw new ArgumentNullException("EncryptionKey"); } diff --git a/src/ServiceManagement/StorSimple/Commands.StorSimple/StorSimpleCmdletBase.cs b/src/ServiceManagement/StorSimple/Commands.StorSimple/StorSimpleCmdletBase.cs index 41afafa30cf3..bb51c61f0a80 100644 --- a/src/ServiceManagement/StorSimple/Commands.StorSimple/StorSimpleCmdletBase.cs +++ b/src/ServiceManagement/StorSimple/Commands.StorSimple/StorSimpleCmdletBase.cs @@ -25,6 +25,7 @@ using System.Net; using System.Management.Automation; using Microsoft.WindowsAzure.Commands.StorSimple.Models; +using System.Text.RegularExpressions; namespace Microsoft.WindowsAzure.Commands.StorSimple { @@ -512,5 +513,10 @@ internal bool ValidTargetDeviceForFailover(string sourceDeviceId, string targetD return true; } + + internal bool IsValidAsciiString(string s) + { + return Regex.IsMatch(s, "[ -~]+"); + } } } \ No newline at end of file