remove excess directory
This commit is contained in:
parent
d5cbbe1b9a
commit
3a7d0be120
1 changed files with 2 additions and 1 deletions
|
@ -353,6 +353,7 @@ torrentFileSizes torrent = do
|
|||
fn = reverse $ drop 2 $
|
||||
dropWhile (/= '(') $ dropWhile (== ')') $ reverse l
|
||||
|
||||
-- a malicious torrent file might try to do directory traversal
|
||||
scrub f = if isAbsolute f || any (== "..") (splitPath f)
|
||||
then error "found unsafe filename in torrent!"
|
||||
else f
|
||||
|
@ -365,4 +366,4 @@ torrentContents u = convert
|
|||
convert l = UrlMulti $ map mkmulti (zip l [1..])
|
||||
|
||||
mkmulti ((fn, sz), n) =
|
||||
(torrentUrlWithNum u n, Just sz, mkSafeFilePath fn)
|
||||
(torrentUrlWithNum u n, Just sz, mkSafeFilePath $ joinPath $ drop 1 $ splitPath fn)
|
||||
|
|
Loading…
Reference in a new issue