From b10c43f1225f3b16404006ec168c262e66a251f0 Mon Sep 17 00:00:00 2001 From: memo Date: Mon, 29 Jul 2024 16:07:56 +0200 Subject: [PATCH] use English locale in toLowerCase() instead of default The default depends on the target machine and may not produce consistent results. --- build.sbt | 2 +- src/main/scala/sc4pac/Constants.scala | 2 +- src/main/scala/sc4pac/Prompt.scala | 2 +- src/main/scala/sc4pac/extractor.scala | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index eb6f2cb..dee1cfa 100644 --- a/build.sbt +++ b/build.sbt @@ -63,7 +63,7 @@ assembly / assemblyJarName := s"${name.value}-cli.jar" // assembly / assemblyMergeStrategy := { case p0 @ PathList("META-INF", xs @ _*) => - (xs.map(_.toLowerCase)) match { + (xs.map(_.toLowerCase(java.util.Locale.ENGLISH))) match { case p1 if p1.last == "module-info.class" => MergeStrategy.discard case p1 if p1.last == "javax.inject.named" => MergeStrategy.filterDistinctLines case p1 if p1.last == "io.netty.versions.properties" => MergeStrategy.filterDistinctLines diff --git a/src/main/scala/sc4pac/Constants.scala b/src/main/scala/sc4pac/Constants.scala index 63801f2..4d704b8 100644 --- a/src/main/scala/sc4pac/Constants.scala +++ b/src/main/scala/sc4pac/Constants.scala @@ -92,5 +92,5 @@ object Constants { true } - def isDll(path: os.Path): Boolean = path.last.toLowerCase.endsWith(".dll") + def isDll(path: os.Path): Boolean = path.last.toLowerCase(java.util.Locale.ENGLISH).endsWith(".dll") } diff --git a/src/main/scala/sc4pac/Prompt.scala b/src/main/scala/sc4pac/Prompt.scala index 1eb178a..b0ab406 100644 --- a/src/main/scala/sc4pac/Prompt.scala +++ b/src/main/scala/sc4pac/Prompt.scala @@ -50,7 +50,7 @@ object Prompt { } yield { if (input.isEmpty) default else { - val matches: Seq[String] = options.filter(_.toLowerCase().startsWith(input.toLowerCase())) + val matches: Seq[String] = options.filter(_.toLowerCase(java.util.Locale.ENGLISH).startsWith(input.toLowerCase(java.util.Locale.ENGLISH))) matches match { case Seq(unique) => Some(unique) case _ => None diff --git a/src/main/scala/sc4pac/extractor.scala b/src/main/scala/sc4pac/extractor.scala index 5f377ff..ead1987 100644 --- a/src/main/scala/sc4pac/extractor.scala +++ b/src/main/scala/sc4pac/extractor.scala @@ -13,7 +13,7 @@ import sc4pac.error.ExtractionFailed object Extractor { def acceptNestedArchive(p: os.BasePath) = { - val name = p.last.toLowerCase + val name = p.last.toLowerCase(java.util.Locale.ENGLISH) name.endsWith(".jar") || name.endsWith(".zip") || name.endsWith(".7z") || name.endsWith(".exe") } @@ -47,7 +47,7 @@ object Extractor { private object WrappedArchive { def apply(file: java.io.File, fallbackFilename: Option[String], stagingRoot: os.Path, logger: Logger, hints: Option[JD.ArchiveType]): WrappedArchive[?] = { - val lcNames: Seq[String] = Seq(file.getName.toLowerCase) ++ fallbackFilename.map(_.toLowerCase) + val lcNames: Seq[String] = Seq(file.getName.toLowerCase(java.util.Locale.ENGLISH)) ++ fallbackFilename.map(_.toLowerCase(java.util.Locale.ENGLISH)) if (lcNames.exists(_.endsWith(".exe")) && hints.exists(_.format.equalsIgnoreCase(JD.ArchiveType.clickteamFormat))) { /* Clickteam installer */ val tempExtractionDir = os.temp.dir(stagingRoot, prefix = "exe", deleteOnExit = false) // the parent stagingRoot is already temporary and will be deleted