on master help sign in
PParser.hs: filename: Add check that path is valid

In addition to ensuring the filename is: - Non-empty - Filename only (no directory separator) This also checks: - No invalid characters are present

commit9229b623df889cc8169a5c52213db71f18d4df72 authorJeremy W. Sherman <jeremyw.sherman@gmail.com> dateTue 13 Oct 2015, 14:56 (11 years ago) parentee589b5
1 file changed+4−2
src/Pkg/PParser.hs+4−2
src/Pkg/PParser.hs+4−2
@@ -14,7 +14,7 @@ import Idris.CmdOptions
1414
1515import Control.Monad.State.Strict
1616import Control.Applicative
17−import System.FilePath (takeFileName)
17+import System.FilePath (takeFileName, isValid)
1818
1919import Util.System
2020
@@ -85,9 +85,11 @@ filename = (do
8585 <?> "filename"
8686 where
8787 isValidFilename :: FilePath -> Bool
88− isValidFilename path = isNonEmpty && hasNoDirectoryComponent
88+ isValidFilename path =
89+ and [isNonEmpty, isValidPath, hasNoDirectoryComponent]
8990 where
9091 isNonEmpty = path /= ""
92+ isValidPath = System.FilePath.isValid path
9193 hasNoDirectoryComponent = path == takeFileName path
9294
9395