mirror of https://github.com/sbt/sbt.git
Merge pull request #321 from alexarchambault/topic/utf-8-bom
Ignore UTF-8 BOM in metadata files
This commit is contained in:
commit
fac264f7b7
|
|
@ -832,6 +832,8 @@ object Cache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val utf8Bom = "\ufeff"
|
||||||
|
|
||||||
def fetch(
|
def fetch(
|
||||||
cache: File = default,
|
cache: File = default,
|
||||||
cachePolicy: CachePolicy = CachePolicy.FetchMissing,
|
cachePolicy: CachePolicy = CachePolicy.FetchMissing,
|
||||||
|
|
@ -853,7 +855,9 @@ object Cache {
|
||||||
val res = if (!f.isDirectory && f.exists()) {
|
val res = if (!f.isDirectory && f.exists()) {
|
||||||
Try(new String(NioFiles.readAllBytes(f.toPath), "UTF-8")) match {
|
Try(new String(NioFiles.readAllBytes(f.toPath), "UTF-8")) match {
|
||||||
case scala.util.Success(content) =>
|
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) =>
|
case scala.util.Failure(e) =>
|
||||||
Left(s"Could not read (file:${f.getCanonicalPath}): ${e.getMessage}")
|
Left(s"Could not read (file:${f.getCanonicalPath}): ${e.getMessage}")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
dk.brics.automaton:automaton:1.11-8:compile
|
||||||
|
|
@ -399,6 +399,13 @@ object CentralTests extends TestSuite {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
'ignoreUtf8Bom - {
|
||||||
|
resolutionCheck(
|
||||||
|
Module("dk.brics.automaton", "automaton"),
|
||||||
|
"1.11-8"
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue