Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict flag names to ASCII #4696

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cabal/Distribution/Parsec/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Data.Functor.Identity (Identity)
import qualified Distribution.Compat.Parsec as P
import Distribution.Parsec.Types.Common
(PWarnType (..), PWarning (..), Position (..))
import Distribution.Utils.Generic (lowercase)
import Distribution.Utils.Generic (isAsciiAlphaNum, lowercase)
import qualified Text.Parsec as Parsec
import qualified Text.Parsec.Language as Parsec
import qualified Text.Parsec.Token as Parsec
Expand Down Expand Up @@ -130,8 +130,8 @@ instance Parsec FlagName where
parsec = mkFlagName . lowercase <$> parsec'
where
parsec' = (:) <$> lead <*> rest
lead = P.satisfy (\c -> isAlphaNum c || c == '_')
rest = P.munch (\c -> isAlphaNum c || c == '_' || c == '-')
lead = P.satisfy (\c -> isAsciiAlphaNum c || c == '_')
rest = P.munch (\c -> isAsciiAlphaNum c || c == '_' || c == '-')

instance Parsec Dependency where
parsec = do
Expand Down
8 changes: 3 additions & 5 deletions Cabal/Distribution/Types/GenericPackageDescription.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module Distribution.Types.GenericPackageDescription (
import Prelude ()
import Distribution.Compat.Prelude
import Distribution.Utils.ShortText
import Distribution.Utils.Generic (lowercase)
import Distribution.Utils.Generic (isAsciiAlphaNum, lowercase)
import qualified Text.PrettyPrint as Disp
import qualified Distribution.Compat.ReadP as Parse
import Distribution.Compat.ReadP ((+++))
Expand Down Expand Up @@ -119,13 +119,11 @@ instance Binary FlagName

instance Text FlagName where
disp = Disp.text . unFlagName
-- Note: we don't check that FlagName doesn't have leading dash,
-- cabal check will do that.
parse = mkFlagName . lowercase <$> parse'
where
parse' = (:) <$> lead <*> rest
lead = Parse.satisfy (\c -> isAlphaNum c || c == '_')
rest = Parse.munch (\c -> isAlphaNum c || c == '_' || c == '-')
lead = Parse.satisfy (\c -> isAsciiAlphaNum c || c == '_')
rest = Parse.munch (\c -> isAsciiAlphaNum c || c == '_' || c == '-')

-- | A 'FlagAssignment' is a total or partial mapping of 'FlagName's to
-- 'Bool' flag values. It represents the flags chosen by the user or
Expand Down