Skip to content

Commit b684654

Browse files
committed
More documentation fixes
1 parent 62f1385 commit b684654

File tree

13 files changed

+72
-54
lines changed

13 files changed

+72
-54
lines changed

Codec/Archive/Tar.hs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ module Codec.Archive.Tar (
8585
-- vulnerabilities have been common in packages handling tar archives.
8686
--
8787
-- The 'extract' and 'unpack' functions check for bad file names. See the
88-
-- 'checkSecurity' function for more details. If you need to do any custom
88+
-- 'Codec.Archive.Tar.Check.checkSecurity' function for more details.
89+
-- If you need to do any custom
8990
-- unpacking then you should use this.
9091

9192
-- ** Tarbombs
@@ -125,7 +126,7 @@ module Codec.Archive.Tar (
125126
-- * Types
126127
-- ** Tar entry type
127128
-- | This module provides only very simple and limited read-only access to
128-
-- the 'Entry' type. If you need access to the details or if you need to
129+
-- the 'GenEntry' type. If you need access to the details or if you need to
129130
-- construct your own entries then also import "Codec.Archive.Tar.Entry".
130131
GenEntry,
131132
Entry,
@@ -163,17 +164,15 @@ module Codec.Archive.Tar (
163164
FormatError(..),
164165
) where
165166

166-
import Codec.Archive.Tar.LongNames
167-
import Codec.Archive.Tar.Types
168-
169-
import Codec.Archive.Tar.Read
170-
import Codec.Archive.Tar.Write
171-
172-
import Codec.Archive.Tar.Pack
173-
import Codec.Archive.Tar.Unpack
174-
import Codec.Archive.Tar.Index (hSeekEndEntryOffset)
175-
176167
import Codec.Archive.Tar.Check
168+
import Codec.Archive.Tar.Entry
169+
import Codec.Archive.Tar.Index (hSeekEndEntryOffset)
170+
import Codec.Archive.Tar.LongNames (decodeLongNames, encodeLongNames, DecodeLongNamesError(..))
171+
import Codec.Archive.Tar.Pack (pack, packAndCheck)
172+
import Codec.Archive.Tar.Read (read, FormatError(..))
173+
import Codec.Archive.Tar.Types (unfoldEntries, foldlEntries, foldEntries, mapEntriesNoFail, mapEntries, Entries, GenEntries(..))
174+
import Codec.Archive.Tar.Unpack (unpack, unpackAndCheck)
175+
import Codec.Archive.Tar.Write (write)
177176

178177
import Control.Applicative ((<|>))
179178
import Control.Exception (Exception, throw, catch, SomeException(..))

Codec/Archive/Tar/Check/Internal.hs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{-# LANGUAGE BangPatterns #-}
22
{-# LANGUAGE DeriveDataTypeable #-}
33
{-# LANGUAGE ViewPatterns #-}
4-
{-# LANGUAGE TypeApplications #-}
54
{-# LANGUAGE RankNTypes #-}
65
{-# LANGUAGE ScopedTypeVariables #-}
76
{-# OPTIONS_GHC -Wno-orphans #-}
7+
{-# OPTIONS_HADDOCK hide #-}
88
-----------------------------------------------------------------------------
99
-- |
1010
-- Module : Codec.Archive.Tar.Check.Internal
@@ -70,17 +70,18 @@ import qualified System.FilePath.Posix as FilePath.Posix
7070
-- link target. A failure in any entry terminates the sequence of entries with
7171
-- an error.
7272
--
73-
-- Whenever possible, consider fusing 'checkSecurity' with packing / unpacking by using
73+
-- Whenever possible, consider fusing 'Codec.Archive.Tar.Check.checkSecurity'
74+
-- with packing / unpacking by using
7475
-- 'Codec.Archive.Tar.packAndCheck' / 'Codec.Archive.Tar.unpackAndCheck'
75-
-- with 'checkEntrySecurity'.
76+
-- with 'Codec.Archive.Tar.Check.checkEntrySecurity'.
7677
-- Not only it is faster, but also alleviates issues with lazy I/O
7778
-- such as exhaustion of file handlers.
7879
checkSecurity
7980
:: Entries e
8081
-> GenEntries FilePath FilePath (Either (Either e DecodeLongNamesError) FileNameError)
8182
checkSecurity = checkEntries checkEntrySecurity . decodeLongNames
8283

83-
-- | Worker of 'checkSecurity'.
84+
-- | Worker of 'Codec.Archive.Tar.Check.checkSecurity'.
8485
--
8586
-- @since 0.6.0.0
8687
checkEntrySecurity :: GenEntry FilePath FilePath -> Maybe FileNameError
@@ -156,12 +157,13 @@ showFileNameError mb_plat err = case err of
156157
-- Given the expected subdirectory, this function checks all entries are within
157158
-- that subdirectroy.
158159
--
159-
-- Note: This check must be used in conjunction with 'checkSecurity'
160-
-- (or 'checkPortability').
160+
-- Note: This check must be used in conjunction with 'Codec.Archive.Tar.Check.checkSecurity'
161+
-- (or 'Codec.Archive.Tar.Check.checkPortability').
161162
--
162-
-- Whenever possible, consider fusing 'checkTarbomb' with packing / unpacking by using
163+
-- Whenever possible, consider fusing 'Codec.Archive.Tar.Check.checkTarbomb'
164+
-- with packing / unpacking by using
163165
-- 'Codec.Archive.Tar.packAndCheck' / 'Codec.Archive.Tar.unpackAndCheck'
164-
-- with 'checkEntryTarbomb'.
166+
-- with 'Codec.Archive.Tar.Check.checkEntryTarbomb'.
165167
-- Not only it is faster, but also alleviates issues with lazy I/O
166168
-- such as exhaustion of file handlers.
167169
checkTarbomb

Codec/Archive/Tar/Index.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module Codec.Archive.Tar.Index (
2626
-- 'lookup' paths in the @tar@ file, and then use 'hReadEntry' to
2727
-- seek to the right part of the file and read the entry.
2828
--
29-
-- An index cannot be used to lookup 'Directory' entries in a tar file;
29+
-- An index cannot be used to lookup 'Codec.Archive.Tar.Directory' entries in a tar file;
3030
-- instead, you will get 'TarDir' entry listing all the entries in the
3131
-- directory.
3232

Codec/Archive/Tar/Index/IntTrie.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE CPP, BangPatterns, PatternGuards #-}
22
{-# LANGUAGE DeriveDataTypeable, ScopedTypeVariables #-}
3+
{-# OPTIONS_HADDOCK hide #-}
34

45
module Codec.Archive.Tar.Index.IntTrie (
56

Codec/Archive/Tar/Index/Internal.hs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE CPP, BangPatterns, PatternGuards #-}
22
{-# LANGUAGE GeneralizedNewtypeDeriving, DeriveDataTypeable #-}
3+
{-# OPTIONS_HADDOCK hide #-}
34

45
-----------------------------------------------------------------------------
56
-- |
@@ -213,14 +214,14 @@ data IndexBuilder
213214
deriving (Eq, Show)
214215

215216
instance NFData IndexBuilder where
216-
rnf (IndexBuilder _ _ _) = () -- fully strict by construction
217+
rnf IndexBuilder{} = () -- fully strict by construction
217218

218219
-- | The initial empty 'IndexBuilder'.
219220
--
220221
empty :: IndexBuilder
221222
empty = IndexBuilder StringTable.empty IntTrie.empty 0
222223

223-
-- | Add the next 'Entry' into the 'IndexBuilder'.
224+
-- | Add the next t'Entry' into the 'IndexBuilder'.
224225
--
225226
addNextEntry :: Entry -> IndexBuilder -> IndexBuilder
226227
addNextEntry entry (IndexBuilder stbl itrie nextOffset) =
@@ -238,7 +239,7 @@ skipNextEntry :: Entry -> IndexBuilder -> IndexBuilder
238239
skipNextEntry entry (IndexBuilder stbl itrie nextOffset) =
239240
IndexBuilder stbl itrie (nextEntryOffset entry nextOffset)
240241

241-
-- | Finish accumulating 'Entry' information and build the compact 'TarIndex'
242+
-- | Finish accumulating t'Entry' information and build the compact 'TarIndex'
242243
-- lookup structure.
243244
--
244245
finalise :: IndexBuilder -> TarIndex
@@ -321,7 +322,7 @@ unfinalise (TarIndex pathTable pathTrie finalOffset) =
321322
-- I/O operations
322323
--
323324

324-
-- | Reads an entire 'Entry' at the given 'TarEntryOffset' in the tar file.
325+
-- | Reads an entire t'Entry' at the given 'TarEntryOffset' in the tar file.
325326
-- The 'Handle' must be open for reading and be seekable.
326327
--
327328
-- This reads the whole entry into memory strictly, not incrementally. For more
@@ -341,7 +342,7 @@ hReadEntry hnd off = do
341342
}
342343
_ -> return entry
343344

344-
-- | Read the header for a 'Entry' at the given 'TarEntryOffset' in the tar
345+
-- | Read the header for a t'Entry' at the given 'TarEntryOffset' in the tar
345346
-- file. The 'entryContent' will contain the correct metadata but an empty file
346347
-- content. The 'Handle' must be open for reading and be seekable.
347348
--
@@ -409,7 +410,7 @@ hSeekEntryContentOffset hnd blockOff =
409410
--
410411
-- After this action, the 'Handle' position is not in any useful place. If
411412
-- you want to skip to the next entry, take the 'TarEntryOffset' returned and
412-
-- use 'hReadEntryHeaderOrEof' again. Or if having inspected the 'Entry'
413+
-- use 'hReadEntryHeaderOrEof' again. Or if having inspected the t'Entry'
413414
-- header you want to read the entry content (if it has one) then use
414415
-- 'hSeekEntryContentOffset' on the original input 'TarEntryOffset'.
415416
--

Codec/Archive/Tar/Index/StringTable.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE CPP, BangPatterns, PatternGuards, DeriveDataTypeable #-}
22
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
3+
{-# OPTIONS_HADDOCK hide #-}
34

45
module Codec.Archive.Tar.Index.StringTable (
56

Codec/Archive/Tar/LongNames.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE LambdaCase #-}
22
{-# LANGUAGE PackageImports #-}
3+
{-# OPTIONS_HADDOCK hide #-}
34

45
module Codec.Archive.Tar.LongNames
56
( encodeLongNames

Codec/Archive/Tar/Pack.hs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{-# LANGUAGE LambdaCase #-}
44
{-# LANGUAGE RankNTypes #-}
55
{-# LANGUAGE ScopedTypeVariables #-}
6+
{-# OPTIONS_HADDOCK hide #-}
67
-----------------------------------------------------------------------------
78
-- |
89
-- Module : Codec.Archive.Tar
@@ -59,9 +60,6 @@ import Codec.Archive.Tar.Check.Internal (checkEntrySecurity)
5960
-- entries. Hard links are treated like ordinary files. Special files like
6061
-- FIFOs (named pipes), sockets or device files will cause problems.
6162
--
62-
-- An exception will be thrown for any file names that are too long to
63-
-- represent as a 'TarPath'.
64-
--
6563
-- * This function returns results lazily. Subdirectories are scanned
6664
-- and files are read one by one as the list of entries is consumed.
6765
-- Do not change their contents before the output of 'pack' was consumed in full.
@@ -75,7 +73,7 @@ pack = packAndCheck (const Nothing)
7573
-- | Like 'pack', but allows to specify additional sanity/security
7674
-- checks on the input filenames. This is useful if you know which
7775
-- check will be used on client side
78-
-- in 'Codec.Tar.Check.unpack' / 'Codec.Tar.Check.unpackAndCheck'.
76+
-- in 'Codec.Archive.Tar.unpack' / 'Codec.Archive.Tar.unpackAndCheck'.
7977
--
8078
-- @since 0.6.0.0
8179
packAndCheck
@@ -128,7 +126,7 @@ interleave = unsafeInterleaveIO . go
128126
xs' <- interleave xs
129127
return (x':xs')
130128

131-
-- | Construct a tar 'Entry' based on a local file.
129+
-- | Construct a tar entry based on a local file.
132130
--
133131
-- This sets the entry size, the data contained in the file and the file's
134132
-- modification time. If the file is executable then that information is also
@@ -138,7 +136,7 @@ interleave = unsafeInterleaveIO . go
138136
--
139137
packFileEntry
140138
:: FilePath -- ^ Full path to find the file on the local disk
141-
-> tarPath -- ^ Path to use for the tar 'Entry' in the archive
139+
-> tarPath -- ^ Path to use for the tar 'GenEntry' in the archive
142140
-> IO (GenEntry tarPath linkTarget)
143141
packFileEntry filepath tarpath = do
144142
mtime <- getModTime filepath
@@ -171,29 +169,29 @@ packFileEntry filepath tarpath = do
171169
, entryTime = mtime
172170
}
173171

174-
-- | Construct a tar 'Entry' based on a local directory (but not its contents).
172+
-- | Construct a tar entry based on a local directory (but not its contents).
175173
--
176174
-- The only attribute of the directory that is used is its modification time.
177175
-- Directory ownership and detailed permissions are not preserved.
178176
--
179177
packDirectoryEntry
180178
:: FilePath -- ^ Full path to find the file on the local disk
181-
-> tarPath -- ^ Path to use for the tar 'Entry' in the archive
179+
-> tarPath -- ^ Path to use for the tar 'GenEntry' in the archive
182180
-> IO (GenEntry tarPath linkTarget)
183181
packDirectoryEntry filepath tarpath = do
184182
mtime <- getModTime filepath
185183
return (directoryEntry tarpath) {
186184
entryTime = mtime
187185
}
188186

189-
-- | Construct a tar 'Entry' based on a local symlink.
187+
-- | Construct a tar entry based on a local symlink.
190188
--
191189
-- This automatically checks symlink safety via 'checkEntrySecurity'.
192190
--
193191
-- @since 0.6.0.0
194192
packSymlinkEntry
195193
:: FilePath -- ^ Full path to find the file on the local disk
196-
-> tarPath -- ^ Path to use for the tar 'Entry' in the archive
194+
-> tarPath -- ^ Path to use for the tar 'GenEntry' in the archive
197195
-> IO (GenEntry tarPath FilePath)
198196
packSymlinkEntry filepath tarpath = do
199197
linkTarget <- getSymbolicLinkTarget filepath

Codec/Archive/Tar/PackAscii.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{-# LANGUAGE PackageImports #-}
2+
{-# OPTIONS_HADDOCK hide #-}
23

34
module Codec.Archive.Tar.PackAscii
45
( toPosixString

Codec/Archive/Tar/Read.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE BangPatterns #-}
22
{-# LANGUAGE PackageImports #-}
3+
{-# OPTIONS_HADDOCK hide #-}
34
-----------------------------------------------------------------------------
45
-- |
56
-- Module : Codec.Archive.Tar.Read

0 commit comments

Comments
 (0)