Ignore UTF-8 BOM in metadata files

Fixes https://github.com/alexarchambault/coursier/issues/316
This commit is contained in:
Alexandre Archambault 2016-08-11 16:23:49 -04:00
parent b6b6f54e17
commit 6aebdac008
3 changed files with 13 additions and 1 deletions

View File

@ -832,6 +832,8 @@ object Cache {
}
}
private val utf8Bom = "\ufeff"
def fetch(
cache: File = default,
cachePolicy: CachePolicy = CachePolicy.FetchMissing,
@ -853,7 +855,9 @@ object Cache {
val res = if (!f.isDirectory && f.exists()) {
Try(new String(NioFiles.readAllBytes(f.toPath), "UTF-8")) match {
case scala.util.Success(content) =>
Right(content)
// stripping any UTF-8 BOM if any, see
// https://github.com/alexarchambault/coursier/issues/316 and the corresponding test
Right(content.stripPrefix(utf8Bom))
case scala.util.Failure(e) =>
Left(s"Could not read (file:${f.getCanonicalPath}): ${e.getMessage}")
}

View File

@ -0,0 +1 @@
dk.brics.automaton:automaton:1.11-8:compile

View File

@ -399,6 +399,13 @@ object CentralTests extends TestSuite {
}
}
}
'ignoreUtf8Bom - {
resolutionCheck(
Module("dk.brics.automaton", "automaton"),
"1.11-8"
)
}
}
}