From 2e109c86d8b4ef5ed92ed7c09e05ad9a93d145c0 Mon Sep 17 00:00:00 2001 From: Chris Done Date: Fri, 4 Mar 2016 14:39:17 +0100 Subject: [PATCH] Reject path consisting of all "." (fixes #13) Ping @mrkkrp --- src/Path.hs | 6 +++--- test/Main.hs | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Path.hs b/src/Path.hs index b32a922..3237bac 100644 --- a/src/Path.hs +++ b/src/Path.hs @@ -116,7 +116,7 @@ parseRelDir filepath = not ("~/" `isPrefixOf` filepath) && not (hasParentDir filepath) && not (null (normalizeDir filepath)) && - filepath /= ".." + not (all (=='.') filepath) then return (Path (normalizeDir filepath)) else throwM (InvalidRelDir filepath) @@ -132,7 +132,7 @@ parseAbsFile filepath = not ("~/" `isPrefixOf` filepath) && not (hasParentDir filepath) && not (null (normalizeFile filepath)) && - filepath /= ".." + not (all (=='.') filepath) then return (Path (normalizeFile filepath)) else throwM (InvalidAbsFile filepath) @@ -151,7 +151,7 @@ parseRelFile filepath = not ("~/" `isPrefixOf` filepath) && not (hasParentDir filepath) && not (null (normalizeFile filepath)) && - filepath /= ".." + not (all (=='.') filepath) then return (Path (normalizeFile filepath)) else throwM (InvalidRelFile filepath) diff --git a/test/Main.hs b/test/Main.hs index 24f6565..b78f56b 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -38,6 +38,7 @@ restrictions = parseFails "~/foo/bar" parseFails "../" parseFails ".." + parseFails "." parseFails "/.." parseFails "/foo/../bar/" parseFails "/foo/bar/.."