Unverified Commit 3d93cdd7 authored by Oleg Grenrus's avatar Oleg Grenrus Committed by GitHub
Browse files

Merge pull request #6588 from phadej/utf8-fix

Add Quirk for single invalid UTF8 file.
parents e070dba5 e4f3a7c4
......@@ -250,7 +250,11 @@ patches = Map.fromList
(Fingerprint 12475837388692175691 18053834261188158945)
(Fingerprint 16279938253437334942 15753349540193002309)
(bsReplace "9223372036854775807" "999")
-- Not UTF8
, mk "Name: nat\nVersion: 0.1\nDescription: Implementation of natural numbers and integers by a binary\n representation. The implementation is supposed to be lazy and\n "
(Fingerprint 9222512268705577108 13085311382746579495)
(Fingerprint 17468921266614378430 13221316288008291892)
(bsReplace "\xf6" "\xc3\xb6")
]
where
mk a b c d = ((a, b), (c, d))
......
......@@ -48,7 +48,7 @@ import Data.Monoid (Sum (..))
import Distribution.PackageDescription.Check (PackageCheck (..), checkPackage)
import Distribution.PackageDescription.PrettyPrint (showGenericPackageDescription)
import Distribution.PackageDescription.Quirks (patchQuirks)
import Distribution.Simple.Utils (fromUTF8BS, toUTF8BS)
import Distribution.Simple.Utils (fromUTF8BS, toUTF8BS, fromUTF8BS)
import System.Directory (getAppUserDataDirectory)
import System.Environment (lookupEnv)
import System.Exit (exitFailure)
......@@ -238,9 +238,9 @@ roundtripTest testFieldsTransform fpath bs = do
-- fromParsecField, "shallow" parser/pretty roundtrip
when testFieldsTransform $
if checkUTF8 bs
if checkUTF8 patchedBs
then do
parsecFields <- assertRight $ Parsec.readFields $ snd $ patchQuirks bs
parsecFields <- assertRight $ Parsec.readFields patchedBs
let prettyFields = PP.fromParsecFields parsecFields
let bs'' = PP.showFields (return []) prettyFields
z0 <- parse "3rd" (toUTF8BS bs'')
......@@ -252,6 +252,8 @@ roundtripTest testFieldsTransform fpath bs = do
return (Sum 1)
where
patchedBs = snd (patchQuirks bs)
checkUTF8 bs' = replacementChar `notElem` fromUTF8BS bs' where
replacementChar = '\xfffd'
......@@ -265,6 +267,7 @@ roundtripTest testFieldsTransform fpath bs = do
assertEqual' bs' x y = unless (x == y || fpath == "ixset/1.0.4/ixset.cabal") $ do
putStrLn fpath
#ifdef MIN_VERSION_tree_diff
putStrLn "====== tree-diff:"
print $ ansiWlEditExprCompact $ ediff x y
#else
putStrLn "<<<<<<"
......@@ -273,6 +276,7 @@ roundtripTest testFieldsTransform fpath bs = do
print y
putStrLn ">>>>>>"
#endif
putStrLn "====== contents:"
putStrLn bs'
exitFailure
......
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