From fc7e63c0aabcbd766cf2d7cd313c7af665ac3ba9 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Sat, 8 Feb 2020 12:55:13 +0100 Subject: [PATCH] Output: Sanitize C# filenames for invalid characters --- Il2CppInspector.Common/Outputs/CSharpCodeStubs.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Il2CppInspector.Common/Outputs/CSharpCodeStubs.cs b/Il2CppInspector.Common/Outputs/CSharpCodeStubs.cs index e6b39d2..43e6293 100644 --- a/Il2CppInspector.Common/Outputs/CSharpCodeStubs.cs +++ b/Il2CppInspector.Common/Outputs/CSharpCodeStubs.cs @@ -263,6 +263,10 @@ namespace Il2CppInspector.Outputs if (!string.IsNullOrEmpty(Path.GetDirectoryName(outFile))) Directory.CreateDirectory(Path.GetDirectoryName(outFile)); + // Sanitize leafname (might be class name with invalid characters) + var leafname = Regex.Replace(Path.GetFileName(outFile), @"[<>:""\|\?\*]", "_"); + outFile = Path.GetDirectoryName(outFile) + Path.DirectorySeparatorChar + leafname; + // Create output file bool fileWritten = false; do {