From b5cff315a13a31111e3efb7e3a9f7afeef9e05f9 Mon Sep 17 00:00:00 2001 From: Magnus Therning Date: Thu, 7 Jan 2016 16:15:06 +0100 Subject: [PATCH] Clarify what limitations the RelX parsers have. Signed-off-by: Magnus Therning --- src/Path.hs | 4 ++++ test/Main.hs | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/Path.hs b/src/Path.hs index 191e915..a1b9a52 100644 --- a/src/Path.hs +++ b/src/Path.hs @@ -93,6 +93,8 @@ parseAbsDir filepath = -- | Get a location for a relative directory. Produces a normalized -- path which always ends in a path separator. -- +-- Note that @filepath@ may contain any number of @./@ but may not consist solely of @./@. It also may not contain a single @..@ anywhere. +-- -- Throws: 'PathParseException' -- parseRelDir :: MonadThrow m @@ -125,6 +127,8 @@ parseAbsFile filepath = -- | Get a location for a relative file. -- +-- Note that @filepath@ may contain any number of @./@ but may not contain a single @..@ anywhere. +-- -- Throws: 'PathParseException' -- parseRelFile :: MonadThrow m diff --git a/test/Main.hs b/test/Main.hs index 40f31d3..24f6565 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -150,12 +150,15 @@ parseRelDirSpec = failing "~/" failing "/" failing "./" + failing "././" failing "//" failing "///foo//bar//mu/" failing "///foo//bar////mu" failing "///foo//bar/.//mu" succeeding "foo.bak" (Path "foo.bak/") succeeding "./foo" (Path "foo/") + succeeding "././foo" (Path "foo/") + succeeding "./foo/./bar" (Path "foo/bar/") succeeding "foo//bar//mu//" (Path "foo/bar/mu/") succeeding "foo//bar////mu" (Path "foo/bar/mu/") succeeding "foo//bar/.//mu" (Path "foo/bar/mu/") @@ -193,6 +196,8 @@ parseRelFileSpec = failing "///foo//bar/.//mu" succeeding "foo.txt" (Path "foo.txt") succeeding "./foo.txt" (Path "foo.txt") + succeeding "././foo.txt" (Path "foo.txt") + succeeding "./foo/./bar.txt" (Path "foo/bar.txt") succeeding "foo//bar//mu.txt" (Path "foo/bar/mu.txt") succeeding "foo//bar////mu.txt" (Path "foo/bar/mu.txt") succeeding "foo//bar/.//mu.txt" (Path "foo/bar/mu.txt")