diff options
author | Ignacio Roldán Etcheverry <neikeq@users.noreply.github.com> | 2021-07-27 05:39:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-27 05:39:19 +0200 |
commit | 8ff29d1879780fe6cdf0d24d6b92bf9a1275bfa3 (patch) | |
tree | e8c5abdc1b0401bebbbb9812cec3494e25be28e0 /modules/mono | |
parent | e6a544c169ae598c1a6f8632f6d8bed1abcdaddc (diff) | |
parent | d636ebbfe9b72f355002331f65067b5b2e165142 (diff) |
Merge pull request #50918 from raulsntos/fix-39432
Ignore paths with invalid chars in PathWhich
Diffstat (limited to 'modules/mono')
-rw-r--r-- | modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs index ee4e7ba9d4..4624439665 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs @@ -113,11 +113,20 @@ namespace GodotTools.Utils { string[] windowsExts = Environment.GetEnvironmentVariable("PATHEXT")?.Split(PathSep) ?? Array.Empty<string>(); string[] pathDirs = Environment.GetEnvironmentVariable("PATH")?.Split(PathSep); + char[] invalidPathChars = Path.GetInvalidPathChars(); var searchDirs = new List<string>(); if (pathDirs != null) - searchDirs.AddRange(pathDirs); + { + foreach (var pathDir in pathDirs) + { + if (pathDir.IndexOfAny(invalidPathChars) != -1) + continue; + + searchDirs.Add(pathDir); + } + } string nameExt = Path.GetExtension(name); bool hasPathExt = !string.IsNullOrEmpty(nameExt) && windowsExts.Contains(nameExt, StringComparer.OrdinalIgnoreCase); @@ -137,11 +146,20 @@ namespace GodotTools.Utils private static string PathWhichUnix([NotNull] string name) { string[] pathDirs = Environment.GetEnvironmentVariable("PATH")?.Split(PathSep); + char[] invalidPathChars = Path.GetInvalidPathChars(); var searchDirs = new List<string>(); if (pathDirs != null) - searchDirs.AddRange(pathDirs); + { + foreach (var pathDir in pathDirs) + { + if (pathDir.IndexOfAny(invalidPathChars) != -1) + continue; + + searchDirs.Add(pathDir); + } + } searchDirs.Add(System.IO.Directory.GetCurrentDirectory()); // last in the list |