Skip to content

Commit

Permalink
Only sanitize archive part of the path (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
sk-zk committed Sep 16, 2024
1 parent 6af2bd3 commit c28e118
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Extractor/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,11 @@ private static void ExtractScs(string scsPath, string[] startPaths,
case EntryType.File:
// TODO make sure this is actually a file
// and not a directory falsely labeled as one
var outputPath = Path.Combine(destination,
startPath.StartsWith('/') ? startPath[1..] : startPath);
var startPathWithoutSlash = startPath.StartsWith('/') ? startPath[1..] : startPath;
var outputPath = Path.Combine(destination, SanitizePath(startPathWithoutSlash));
Console.Out.WriteLine($"Extracting {ReplaceControlChars(startPath)} ...");
outputPath = SanitizePath(outputPath);
ExtractToFile(startPath, outputPath, () => reader.ExtractToFile(startPath, outputPath));
ExtractToFile(startPathWithoutSlash, outputPath,
() => reader.ExtractToFile(startPathWithoutSlash, outputPath));
break;
case EntryType.NotFound:
if (startPath == "/")
Expand Down Expand Up @@ -278,7 +278,7 @@ private static void ExtractRaw(string scsPath)
// subdirectory listings are useless because the file names are relative
if (entry.IsDirectory) continue;

var outputPath = SanitizePath(Path.Combine(outputDir, key.ToString("x")));
var outputPath = Path.Combine(outputDir, key.ToString("x"));
ExtractToFile(key.ToString("x"), outputPath, () => reader.ExtractToFile(entry, "", outputPath));
}

Expand Down Expand Up @@ -340,7 +340,7 @@ private static void ExtractFiles(IHashFsReader reader, List<string> files)
// The directory listing of core.scs only lists itself, but as a file, breaking everything
if (file == "/") continue;

var outputPath = SanitizePath(Path.Combine(destination, file[1..]));
var outputPath = Path.Combine(destination, SanitizePath(file[1..]));
ExtractToFile(file, outputPath, () => reader.ExtractToFile(file, outputPath));
}
}
Expand Down

0 comments on commit c28e118

Please sign in to comment.