Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added acceptense for more possible forms of checksum patterns #640

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion cache/src/main/scala/coursier/Cache.scala
Expand Up @@ -884,7 +884,12 @@ object Cache {
findChecksum(lines.map(_.toLowerCase.replaceAll("\\s", "")))

private def parseChecksumAlternative(lines: Seq[String]): Option[BigInteger] =
findChecksum(lines.flatMap(_.toLowerCase.split("\\s+")))
findChecksum(lines.flatMap(_.toLowerCase.split("\\s+"))) orElse {
findChecksum(lines.map(_.toLowerCase
.split("\\s+")
.filter(_.matches("[0-9a-f]+"))
.mkString))
}

def validateChecksum(
artifact: Artifact,
Expand Down
11 changes: 11 additions & 0 deletions tests/jvm/src/test/scala/coursier/test/ChecksumTests.scala
Expand Up @@ -46,6 +46,17 @@ object ChecksumTests extends TestSuite {
sha1ParseTest(cleanSha1, dirtySha1)
}

'singleLineEndingWithChunkedSha1 - {
// http://www-eu.apache.org/dist/kafka/0.10.1.0/kafka_2.11-0.10.1.0.tgz.sha1
// as of 2017-08-17
val dirtySha1 =
"kafka_2.11-0.10.1.0.tgz: 710F 31E7 0AB7 54BF D533 3278 E226 82C9 8DD0 56CA\n"

val cleanSha1 = "710f31e70ab754bfd5333278e22682c98dd056ca"

sha1ParseTest(cleanSha1, dirtySha1)
}

'binarySha1 - {
val content = Platform.readFullySync(getClass.getResource("/empty.sha1").openStream())
val res = Cache.parseRawChecksum(content)
Expand Down