From 729565dee1175ecb888ce2e34ae92007382d1e69 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Sat, 17 Jan 2026 12:10:26 +0000 Subject: [PATCH 1/2] Fix "." and ".." in archives being extracted wrong --- .../Decompress/BaseDecompressArchiveAction.cs | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/Files.App/Actions/Content/Archives/Decompress/BaseDecompressArchiveAction.cs b/src/Files.App/Actions/Content/Archives/Decompress/BaseDecompressArchiveAction.cs index 1c630e6d0d62..fa8a9ae802bb 100644 --- a/src/Files.App/Actions/Content/Archives/Decompress/BaseDecompressArchiveAction.cs +++ b/src/Files.App/Actions/Content/Archives/Decompress/BaseDecompressArchiveAction.cs @@ -91,15 +91,29 @@ protected async Task DecompressArchiveHereAsync(bool smart = false) if (zipFile is null) return true; - return zipFile.ArchiveFileData.Select(file => + static string? GetFirstMeaningfulSegment(string? fileName) { - var pathCharIndex = file.FileName.IndexOfAny(['/', '\\']); - if (pathCharIndex == -1) - return file.FileName; - else - return file.FileName.Substring(0, pathCharIndex); - }) - .Distinct().Count() > 1; + if (string.IsNullOrEmpty(fileName)) + return null; + + var parts = fileName.Split(['/', '\\'], StringSplitOptions.RemoveEmptyEntries); + foreach (var part in parts) + { + if (part is "." or "..") + continue; + return part; + } + + return null; + } + + var topLevelEntries = zipFile.ArchiveFileData + .Select(file => GetFirstMeaningfulSegment(file.FileName)) + .Where(x => !string.IsNullOrEmpty(x)) + .Distinct() + .Count(); + + return topLevelEntries > 1; }); if (smart && currentFolder is not null && isMultipleItems) From f8b0984221f4a103715df1de97a82dd6145fbb28 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Sat, 24 Jan 2026 09:07:01 +0000 Subject: [PATCH 2/2] Respond to Copilot comment (just a general readability refactor, no impact made) --- .../Archives/Decompress/BaseDecompressArchiveAction.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Files.App/Actions/Content/Archives/Decompress/BaseDecompressArchiveAction.cs b/src/Files.App/Actions/Content/Archives/Decompress/BaseDecompressArchiveAction.cs index fa8a9ae802bb..c043fa265886 100644 --- a/src/Files.App/Actions/Content/Archives/Decompress/BaseDecompressArchiveAction.cs +++ b/src/Files.App/Actions/Content/Archives/Decompress/BaseDecompressArchiveAction.cs @@ -97,12 +97,8 @@ protected async Task DecompressArchiveHereAsync(bool smart = false) return null; var parts = fileName.Split(['/', '\\'], StringSplitOptions.RemoveEmptyEntries); - foreach (var part in parts) - { - if (part is "." or "..") - continue; + foreach (var part in parts.Where(part => part is not "." and not "..")) return part; - } return null; }