From ae00e7bb36fb661b65ef29f94d3043b0935d1035 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Fri, 25 Aug 2023 11:31:04 -0500 Subject: [PATCH 1/2] Handle backslashes in ZIP paths --- Core/Types/ModuleInstallDescriptor.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Core/Types/ModuleInstallDescriptor.cs b/Core/Types/ModuleInstallDescriptor.cs index 49095dbf97..b34b9411a4 100644 --- a/Core/Types/ModuleInstallDescriptor.cs +++ b/Core/Types/ModuleInstallDescriptor.cs @@ -427,8 +427,13 @@ public List FindInstallableFiles(ZipFile zipfile, GameInstance // Surely there's a better way, although this is fast enough we may not care. foreach (ZipEntry entry in zipfile) { + // Backslashes are not allowed in filenames according to the ZIP spec, + // but there's a non-conformant PowerShell tool that uses them anyway. + // Try to accommodate those mods. + string entryName = entry.Name.Replace('\\', '/'); + // Skips dirs and things not prescribed by our install stanza. - if (!IsWanted(entry.Name, shortestMatch)) + if (!IsWanted(entryName, shortestMatch)) { continue; } @@ -447,7 +452,7 @@ public List FindInstallableFiles(ZipFile zipfile, GameInstance // Get the full name of the file. // Update our file info with the install location file_info.destination = TransformOutputName( - ksp.game, entry.Name, installDir, @as); + ksp.game, entryName, installDir, @as); file_info.makedir = AllowDirectoryCreation( ksp.game, ksp?.ToRelativeGameDir(file_info.destination) From 46cc1082960af75db577ef12970cd9eba5d8590e Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Sat, 26 Aug 2023 09:18:08 -0500 Subject: [PATCH 2/2] Inflation error for null or empty install stanza properties --- Netkan/Validators/InstallValidator.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Netkan/Validators/InstallValidator.cs b/Netkan/Validators/InstallValidator.cs index 9312f35885..151d44c9db 100644 --- a/Netkan/Validators/InstallValidator.cs +++ b/Netkan/Validators/InstallValidator.cs @@ -87,6 +87,10 @@ public void Validate(Metadata metadata) if (stanza.ContainsKey(propName)) { string val = (string)stanza[propName]; + if (string.IsNullOrEmpty(val)) + { + throw new Kraken($"Install property '{propName}' is null or empty"); + } string norm = CKANPathUtils.NormalizePath(val); if (val != norm) {