From c8e5e90b0e1068be66f453f9307679460bf62e32 Mon Sep 17 00:00:00 2001 From: Alexander Vogt Date: Wed, 21 Feb 2024 13:37:47 +0100 Subject: [PATCH 1/2] check both slahes --- core/src/main/java/de/jplag/reporting/FilePathUtil.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/de/jplag/reporting/FilePathUtil.java b/core/src/main/java/de/jplag/reporting/FilePathUtil.java index 51aefdd36..2ba56c9bf 100644 --- a/core/src/main/java/de/jplag/reporting/FilePathUtil.java +++ b/core/src/main/java/de/jplag/reporting/FilePathUtil.java @@ -8,6 +8,7 @@ public final class FilePathUtil { private static final String ZIP_PATH_SEPARATOR = "/"; // Paths in zip files are always separated by a slash + private static final String WINDOWS_PATH_SEPARATOR = "\\"; private FilePathUtil() { // private constructor to prevent instantiation @@ -35,12 +36,12 @@ public static String getRelativeSubmissionPath(File file, Submission submission, */ public static String joinZipPathSegments(String left, String right) { String rightStripped = right; - while (rightStripped.startsWith(ZIP_PATH_SEPARATOR)) { + while (rightStripped.startsWith(ZIP_PATH_SEPARATOR) || rightStripped.startsWith(WINDOWS_PATH_SEPARATOR)) { rightStripped = rightStripped.substring(1); } String leftStripped = left; - while (leftStripped.endsWith(ZIP_PATH_SEPARATOR)) { + while (leftStripped.endsWith(ZIP_PATH_SEPARATOR) || rightStripped.startsWith(WINDOWS_PATH_SEPARATOR)) { leftStripped = leftStripped.substring(0, leftStripped.length() - 1); } From f72d745d720fabe7e40b1ca0d549b680c06ee978 Mon Sep 17 00:00:00 2001 From: Alexander Vogt Date: Wed, 21 Feb 2024 13:44:26 +0100 Subject: [PATCH 2/2] fix left side check --- core/src/main/java/de/jplag/reporting/FilePathUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/de/jplag/reporting/FilePathUtil.java b/core/src/main/java/de/jplag/reporting/FilePathUtil.java index 2ba56c9bf..aff67ef3e 100644 --- a/core/src/main/java/de/jplag/reporting/FilePathUtil.java +++ b/core/src/main/java/de/jplag/reporting/FilePathUtil.java @@ -41,7 +41,7 @@ public static String joinZipPathSegments(String left, String right) { } String leftStripped = left; - while (leftStripped.endsWith(ZIP_PATH_SEPARATOR) || rightStripped.startsWith(WINDOWS_PATH_SEPARATOR)) { + while (leftStripped.endsWith(ZIP_PATH_SEPARATOR) || leftStripped.startsWith(WINDOWS_PATH_SEPARATOR)) { leftStripped = leftStripped.substring(0, leftStripped.length() - 1); }