Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
8a569d87
Commit
8a569d87
authored
Mar 20, 2020
by
Oleg Grenrus
Browse files
Make input valid UTF8 if it isn't in parseGenericPackageDescription
parent
95283a5d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Cabal/Distribution/PackageDescription/Parsec.hs
View file @
8a569d87
...
...
@@ -60,7 +60,7 @@ import Distribution.Parsec.Newtypes (CommaFSep, List, SpecVersi
import
Distribution.Parsec.Position
(
Position
(
..
),
zeroPos
)
import
Distribution.Parsec.Warning
(
PWarnType
(
..
))
import
Distribution.Pretty
(
prettyShow
)
import
Distribution.Simple.Utils
(
fromUTF8BS
)
import
Distribution.Simple.Utils
(
fromUTF8BS
,
toUTF8BS
)
import
Distribution.Types.CondTree
import
Distribution.Types.Dependency
(
Dependency
)
import
Distribution.Types.ForeignLib
...
...
@@ -109,12 +109,12 @@ parseGenericPackageDescription bs = do
"Unsupported cabal-version. See https://github.com/haskell/cabal/issues/4899."
_
->
pure
()
case
readFields'
bs'
of
case
readFields'
bs'
'
of
Right
(
fs
,
lexWarnings
)
->
do
when
patched
$
parseWarning
zeroPos
PWTQuirkyCabalFile
"Legacy cabal file"
-- UTF8 is validated in a prepass step, afterwards parsing is lenient.
parseGenericPackageDescription'
ver
lexWarnings
(
valid
ateUTF8
bs'
)
fs
parseGenericPackageDescription'
ver
lexWarnings
in
valid
Utf8
fs
-- TODO: better marshalling of errors
Left
perr
->
parseFatalFailure
pos
(
show
perr
)
where
ppos
=
P
.
errorPos
perr
...
...
@@ -123,6 +123,14 @@ parseGenericPackageDescription bs = do
(
patched
,
bs'
)
=
patchQuirks
bs
ver
=
scanSpecVersion
bs'
invalidUtf8
=
validateUTF8
bs'
-- if there are invalid utf8 characters, we make the bytestring valid.
bs''
=
case
invalidUtf8
of
Nothing
->
bs'
Just
_
->
toUTF8BS
(
fromUTF8BS
bs'
)
-- | 'Maybe' variant of 'parseGenericPackageDescription'
parseGenericPackageDescriptionMaybe
::
BS
.
ByteString
->
Maybe
GenericPackageDescription
parseGenericPackageDescriptionMaybe
=
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment