From 397c99bd0c7d24c8c665d7f26b32f71ac350f37f Mon Sep 17 00:00:00 2001 From: David Alvarez Date: Tue, 9 Jun 2026 13:35:35 +0200 Subject: [PATCH] fix: backslash path splitting bug in ConfigPatcher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: the separator check used '\\\\'.equals(sep) comparing a 2-char Java string literal to a 1-char substring result — always false. This caused backslash paths (C:\FALLOUT1\MASTER.DAT) to never be split into components, so stale prefixes were never detected or rewritten. Fix: use char comparison (sep == '\\') which correctly identifies the separator type. Affected both findReplacement and existsIgnoreCase. This was a pre-existing bug from the original UploadResource code that was carried over during the refactor. Re-uploading Fallout after this fix will correctly patch FALLOUT.CFG paths. --- src/main/java/com/dostalgia/ConfigPatcher.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/dostalgia/ConfigPatcher.java b/src/main/java/com/dostalgia/ConfigPatcher.java index 47a8df8..2286696 100644 --- a/src/main/java/com/dostalgia/ConfigPatcher.java +++ b/src/main/java/com/dostalgia/ConfigPatcher.java @@ -86,10 +86,10 @@ public class ConfigPatcher { private static String findReplacement(String fullPath, Path extractDir, Set seenPrefixes) { String drivePrefix = fullPath.substring(0, 2); - String sep = fullPath.substring(2, 3); + char sep = fullPath.charAt(2); + String splitRegex = sep == '\\' ? "\\\\" : "/"; String relPath = fullPath.substring(3); - String splitter = "\\\\".equals(sep) ? "\\\\\\\\" : "/"; - String[] parts = relPath.split(splitter, -1); + String[] parts = relPath.split(splitRegex, -1); for (int skip = 0; skip < parts.length; skip++) { StringBuilder suffix = new StringBuilder(); @@ -122,8 +122,8 @@ public class ConfigPatcher { } private static boolean existsIgnoreCase(Path base, String relativePath) { - String sep = relativePath.contains("\\") ? "\\\\\\\\" : "/"; - String[] parts = relativePath.split(sep, -1); + char sep = relativePath.contains("\\") ? '\\' : '/'; + String[] parts = relativePath.split(sep == '\\' ? "\\\\" : "/", -1); Path current = base; try { for (int i = 0; i < parts.length; i++) {