diff --git a/base/src/main/java/proguard/UpToDateChecker.java b/base/src/main/java/proguard/UpToDateChecker.java index f89cf0da..69b2a512 100644 --- a/base/src/main/java/proguard/UpToDateChecker.java +++ b/base/src/main/java/proguard/UpToDateChecker.java @@ -136,7 +136,11 @@ public void updateInputModificationTime(URL url) { updateModificationTime(new File(url.toURI()), false); } - catch (URISyntaxException ignore) {} + catch (URISyntaxException exception) + { + // The input couldn't be checked, so conservatively consider the output outdated. + throw new IllegalStateException("Can't check the input modification time", exception); + } } } diff --git a/base/src/test/kotlin/proguard/UpToDateCheckerTest.kt b/base/src/test/kotlin/proguard/UpToDateCheckerTest.kt new file mode 100644 index 00000000..a5f06c54 --- /dev/null +++ b/base/src/test/kotlin/proguard/UpToDateCheckerTest.kt @@ -0,0 +1,37 @@ +package proguard + +import io.kotest.assertions.throwables.shouldNotThrowAny +import io.kotest.core.spec.style.FreeSpec +import java.io.File +import java.net.URL +import java.nio.file.Files + +class UpToDateCheckerTest : FreeSpec({ + "An invalid file URI does not hide an outdated obfuscation dictionary" { + val directory = Files.createTempDirectory("proguard-up-to-date-test").toFile() + + try { + val output = File(directory, "output.jar").apply { + createNewFile() + setLastModified(1_000L) + } + val dictionary = File(directory, "dictionary with spaces.txt").apply { + createNewFile() + setLastModified(2_000L) + } + + val configuration = Configuration().apply { + programJars = ClassPath().apply { + add(ClassPathEntry(output, true)) + } + obfuscationDictionary = URL(dictionary.toURI().toString().replace("%20", " ")) + } + + shouldNotThrowAny { + UpToDateChecker(configuration).check() + } + } finally { + directory.deleteRecursively() + } + } +})