Skip to content

Commit

Permalink
Merge pull request #2397 from Blaisorblade/1810-unicode-normalized-pk…
Browse files Browse the repository at this point in the history
…g-name-comparison

Fix #1810: Unicode-normalized pkg name comparison
  • Loading branch information
Blaisorblade authored Aug 2, 2016
2 parents d501da6 + ccb120e commit ccc7229
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/Stack/Solver.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import qualified System.Directory as D
import qualified System.FilePath as FP
import System.Process.Read

import qualified Data.Text.Normalize as T ( normalize , NormalizationMode(NFC) )

data ConstraintType = Constraint | Preference deriving (Eq)
type ConstraintSpec = Map PackageName (Version, Map FlagName Bool)
Expand Down Expand Up @@ -560,8 +561,9 @@ cabalPackagesCheck cabalfps noPkgMsg dupErrMsg = do
-- Just the latter check is enough to cover both the cases

let packages = zip cabalfps gpds
normalizeString = T.unpack . T.normalize T.NFC . T.pack
getNameMismatchPkg (fp, gpd)
| (show . gpdPackageName) gpd /= (FP.takeBaseName . toFilePath) fp
| (normalizeString . show . gpdPackageName) gpd /= (normalizeString . FP.takeBaseName . toFilePath) fp
= Just fp
| otherwise = Nothing
nameMismatchPkgs = mapMaybe getNameMismatchPkg packages
Expand Down
1 change: 1 addition & 0 deletions stack-7.8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ extra-deps:
- th-orphans-0.13.1
- base-orphans-0.5.4
- tar-0.5.0.3
- unicode-transforms-0.1.0.1
flags:
time-locale-compat:
old-locale: false
1 change: 1 addition & 0 deletions stack-8.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ extra-deps:
- http-client-0.5.0
- http-conduit-2.2.0
- http-client-tls-0.3.0
- unicode-transforms-0.1.0.1
1 change: 1 addition & 0 deletions stack.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ library
, tls >= 1.3.8
, transformers >= 0.3.0.0 && < 0.6
, transformers-base >= 0.4.4
, unicode-transforms >= 0.1 && <0.2
, unix-compat
, unordered-containers >= 0.2.5.1
, vector >= 0.10.12.3 && < 0.12
Expand Down
1 change: 1 addition & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ extra-deps:
- http-client-tls-0.3.0
- http-conduit-2.2.0
- path-0.5.8
- unicode-transforms-0.1.0.1
3 changes: 0 additions & 3 deletions test/integration/lib/StackTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ exeExt = if isWindows then ".exe" else ""
-- | Is the OS Windows?
isWindows = os == "mingw32"

-- | Is the OS Mac OS X?
isMacOSX = os == "darwin"

-- | To avoid problems with GHC version mismatch when a new LTS major
-- version is released, pass this argument to @stack@ when running in
-- a global context. The LTS major version here should match that of
Expand Down
3 changes: 1 addition & 2 deletions test/integration/tests/1336-1337-new-package-names/Main.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import StackTest
import Control.Monad
import System.Directory
import System.FilePath

Expand All @@ -18,7 +17,7 @@ main =
stackErr ["new", "44444444444444"]
stackErr ["new", "abc-1"]
stackErr ["new", "444-ば日本-4本"]
unless isMacOSX $ stack ["new", "ば日本-4本"]
stack ["new", "ば日本-4本"]
stack ["new", "אבהץש"]
stack ["new", "ΔΘΩϬ"]
doesExist "./ΔΘΩϬ/stack.yaml"
Expand Down

0 comments on commit ccc7229

Please sign in to comment.