From d0404c8048be1510883d696aab7932d70fb9058d Mon Sep 17 00:00:00 2001 From: jesusalvino Date: Wed, 13 Apr 2022 23:51:07 -0500 Subject: [PATCH 1/9] Preventing Special Characters in the Publish Package --- src/DynamoCore/Search/SearchDictionary.cs | 12 +- .../Properties/Resources.Designer.cs | 2 +- .../Properties/Resources.en-US.resx | 2 +- src/DynamoCoreWpf/Properties/Resources.resx | 2 +- .../UI/Themes/Modern/DynamoModern.xaml | 156 ++++++++++++++---- .../PackageManager/PublishPackageViewModel.cs | 56 ++++++- .../PackageManager/PublishPackageView.xaml | 3 +- 7 files changed, 189 insertions(+), 44 deletions(-) diff --git a/src/DynamoCore/Search/SearchDictionary.cs b/src/DynamoCore/Search/SearchDictionary.cs index c14deb84ce2..476987cf842 100644 --- a/src/DynamoCore/Search/SearchDictionary.cs +++ b/src/DynamoCore/Search/SearchDictionary.cs @@ -323,11 +323,17 @@ private static string[] SplitOnWhiteSpace(string s) return s.Split(null); } - private static bool ContainsSpecialCharacters(string element) + public static Char[] SpecialAndInvalidCharacters() { - return element.Contains("*") || element.Contains(".") || element.Contains(" ") - || element.Contains("\\"); + return new[] { '*', '.', ' ', '\\', '/', ':', '?', '<', '>', '|', '"' }; } + + public static bool ContainsSpecialCharacters(string element) + { + Char[] invalidCharacters = SpecialAndInvalidCharacters(); + return (!string.IsNullOrEmpty(element) && element.IndexOfAny(invalidCharacters) >= 0); + } + #endregion /// diff --git a/src/DynamoCoreWpf/Properties/Resources.Designer.cs b/src/DynamoCoreWpf/Properties/Resources.Designer.cs index 167b0a73b40..ee0e3ffb027 100644 --- a/src/DynamoCoreWpf/Properties/Resources.Designer.cs +++ b/src/DynamoCoreWpf/Properties/Resources.Designer.cs @@ -4795,7 +4795,7 @@ public static string PackageManagerPackageUpdated { } /// - /// Looks up a localized string similar to The name of the package cannot contain /,\, or *.. + /// Looks up a localized string similar to The name of the package cannot contain. /// public static string PackageNameCannotContainTheseCharacters { get { diff --git a/src/DynamoCoreWpf/Properties/Resources.en-US.resx b/src/DynamoCoreWpf/Properties/Resources.en-US.resx index c5aae02a7b5..bfd1f4eb749 100644 --- a/src/DynamoCoreWpf/Properties/Resources.en-US.resx +++ b/src/DynamoCoreWpf/Properties/Resources.en-US.resx @@ -1528,7 +1528,7 @@ Next assemblies were loaded several times: {0} - The name of the package cannot contain /,\, or *. + The name of the package cannot contain ErrorString diff --git a/src/DynamoCoreWpf/Properties/Resources.resx b/src/DynamoCoreWpf/Properties/Resources.resx index e3c0eb3c4c4..8804ecc1a21 100644 --- a/src/DynamoCoreWpf/Properties/Resources.resx +++ b/src/DynamoCoreWpf/Properties/Resources.resx @@ -1640,7 +1640,7 @@ If the toggle is off custom packages that are not already loaded will load once ErrorString - The name of the package cannot contain /,\, or *. + The name of the package cannot contain ErrorString diff --git a/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml b/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml index 1b17564834c..7dda090c298 100644 --- a/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml +++ b/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml @@ -119,6 +119,40 @@ + + + + + + + @@ -723,6 +757,94 @@ + + - - - - - - -