From 807224ce24e6453920e57eff3c4784eb192f7d21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Varga?= Date: Wed, 31 Jul 2024 11:07:40 +0200 Subject: [PATCH] fix: Escape dependency jar lock file's name (#77) --- .../robolectric/internal/JUnit5MavenDependencyResolver.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5MavenDependencyResolver.kt b/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5MavenDependencyResolver.kt index a622ff8..47784e3 100644 --- a/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5MavenDependencyResolver.kt +++ b/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5MavenDependencyResolver.kt @@ -63,7 +63,8 @@ internal class JUnit5MavenDependencyResolver private constructor( } private fun createLockFile(dependencyJar: DependencyJar): File { - return File(System.getProperty("user.home"), "${dependencyJar.shortName}.lock") + val lockFileName = dependencyJar.shortName.replace(SPECIAL_CHARACTERS_IN_FILE_NAME_REGEX.toRegex(), "_") + return File(System.getProperty("user.home"), "$lockFileName.lock") } @Suppress("NestedBlockDepth") @@ -83,4 +84,8 @@ internal class JUnit5MavenDependencyResolver private constructor( lockFile.delete() } } + + private companion object { + private const val SPECIAL_CHARACTERS_IN_FILE_NAME_REGEX = """[<>:"\\/|\?\*]""" + } }