This commit is contained in:
Alexandre Archambault 2017-05-11 17:48:44 +02:00
parent fc38828818
commit 2f0eb1dba8
3 changed files with 12 additions and 4 deletions

View File

@ -957,8 +957,6 @@ object Cache {
}
}
private val utf8Bom = "\ufeff"
def fetch(
cache: File = default,
cachePolicy: CachePolicy = CachePolicy.UpdateChanging,
@ -981,7 +979,7 @@ object Cache {
def notFound(f: File) = Left(s"${f.getCanonicalPath} not found")
def read(f: File) =
try Right(new String(FileUtil.readAllBytes(f), "UTF-8").stripPrefix(utf8Bom))
try Right(new String(FileUtil.readAllBytes(f), "UTF-8"))
catch {
case NonFatal(e) =>
Left(s"Could not read (file:${f.getCanonicalPath}): ${e.getMessage}")

View File

@ -14,9 +14,11 @@ package object compatibility {
def letter = c.isLetter
}
private val utf8Bom = "\ufeff"
def xmlParse(s: String): Either[String, Xml.Node] = {
def parse =
try Right(scala.xml.XML.loadString(s))
try Right(scala.xml.XML.loadString(s.stripPrefix(utf8Bom)))
catch { case e: Exception => Left(e.toString + Option(e.getMessage).fold("")(" (" + _ + ")")) }
def fromNode(node: scala.xml.Node): Xml.Node =

View File

@ -32,6 +32,14 @@ object CentralTests extends TestSuite {
)
.process
.run(fetch)
.map { res =>
assert(res.metadataErrors.isEmpty)
assert(res.conflicts.isEmpty)
assert(res.isDone)
res
}
.runF
}