on master help sign in
PParser.hs: filename: Add check that path is valid
9229b62Jeremy W. Sherman
src/Pkg/PParser.hs+4−2
@@ -14,7 +14,7 @@ import Idris.CmdOptions
14
14
15import Control.Monad.State.Strict
15import Control.Monad.State.Strict
16import Control.Applicative
16import Control.Applicative
17−import System.FilePath (takeFileName)
17+import System.FilePath (takeFileName, isValid)
18
18
19import Util.System
19import Util.System
20
20
@@ -85,9 +85,11 @@ filename = (do
85 <?> "filename"
85 <?> "filename"
86 where
86 where
87 isValidFilename :: FilePath -> Bool
87 isValidFilename :: FilePath -> Bool
88+ isValidFilename path =
88− isValidFilename path = isNonEmpty && hasNoDirectoryComponent
89+ and [isNonEmpty, isValidPath, hasNoDirectoryComponent]
89 where
90 where
90 isNonEmpty = path /= ""
91 isNonEmpty = path /= ""
92+ isValidPath = System.FilePath.isValid path
91 hasNoDirectoryComponent = path == takeFileName path
93 hasNoDirectoryComponent = path == takeFileName path
92
94
93
95