Commit 8fde866a authored by Oleg Grenrus's avatar Oleg Grenrus
Browse files

Ignore bom when reading cabal files from index tarball

parent c9f47d60
......@@ -116,6 +116,7 @@ module Distribution.Simple.Utils (
-- * BOM
startsWithBOM,
fileHasBOM,
ignoreBOM,
-- * generic utils
dropWhileEndLE,
......
......@@ -59,7 +59,7 @@ import Distribution.Text
import Distribution.Verbosity
( Verbosity, normal, lessVerbose )
import Distribution.Simple.Utils
( die, warn, info, fromUTF8 )
( die, warn, info, fromUTF8, ignoreBOM )
import Data.Char (isAlphaNum)
import Data.Maybe (mapMaybe, fromMaybe)
......@@ -349,7 +349,7 @@ extractPkg entry blockNo = case Tar.entryContent entry of
Just ver -> Just $ return (NormalPackage pkgid descr content blockNo)
where
pkgid = PackageIdentifier (PackageName pkgname) ver
parsed = parsePackageDescription . fromUTF8 . BS.Char8.unpack
parsed = parsePackageDescription . ignoreBOM . fromUTF8 . BS.Char8.unpack
$ content
descr = case parsed of
ParseOk _ d -> d
......@@ -497,7 +497,7 @@ packageIndexFromCache mkPkg hnd entrs mode = accum mempty [] entrs
readPackageDescription :: ByteString -> IO GenericPackageDescription
readPackageDescription content =
case parsePackageDescription . fromUTF8 . BS.Char8.unpack $ content of
case parsePackageDescription . ignoreBOM . fromUTF8 . BS.Char8.unpack $ content of
ParseOk _ d -> return d
_ -> interror "failed to parse .cabal file"
......
......@@ -72,7 +72,7 @@ import Distribution.Text
( Text(..), display )
import Distribution.Verbosity (Verbosity)
import Distribution.Simple.Utils
( die, warn, intercalate, fromUTF8, lowercase )
( die, warn, intercalate, fromUTF8, lowercase, ignoreBOM )
import Data.List
( find, nub )
......@@ -542,7 +542,7 @@ readPackageTarget verbosity target = case target of
parsePackageDescription' :: BS.ByteString -> Maybe GenericPackageDescription
parsePackageDescription' content =
case parsePackageDescription . fromUTF8 . BS.Char8.unpack $ content of
case parsePackageDescription . ignoreBOM . fromUTF8 . BS.Char8.unpack $ content of
ParseOk _ pkg -> Just pkg
_ -> Nothing
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment