C#: Fix regression in path name sanitization

This commit is contained in:
Katy Coe
2020-12-09 17:36:05 +01:00
parent 7e25fa9d1d
commit 3b8e518b7c

View File

@@ -292,7 +292,7 @@ namespace Il2CppInspector.Outputs
var usings = nsRefs.OrderBy(n => (n.StartsWith("System.") || n == "System") ? "0" + n : "1" + n);
// Ensure output directory exists and is not a file
var dir = Regex.Replace(Path.GetDirectoryName(outFile), @"[<>:""\|\?\*]", "_");
var dir = string.Join("_", Path.GetDirectoryName(outFile).Split(Path.GetInvalidPathChars()));
if (!string.IsNullOrEmpty(dir)) {
try {
Directory.CreateDirectory(dir);
@@ -304,7 +304,8 @@ namespace Il2CppInspector.Outputs
}
// Sanitize leafname (might be class name with invalid characters)
var leafname = Regex.Replace(Path.GetFileName(outFile), @"[<>:""\|\?\*]", "_");
var leafname = string.Join("_", Path.GetFileName(outFile).Split(Path.GetInvalidFileNameChars()));
outFile = Path.Combine(dir, leafname);
// Create output file