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 $
|
fn = reverse $ drop 2 $
|
||||||
dropWhile (/= '(') $ dropWhile (== ')') $ reverse l
|
dropWhile (/= '(') $ dropWhile (== ')') $ reverse l
|
||||||
|
|
||||||
|
-- a malicious torrent file might try to do directory traversal
|
||||||
scrub f = if isAbsolute f || any (== "..") (splitPath f)
|
scrub f = if isAbsolute f || any (== "..") (splitPath f)
|
||||||
then error "found unsafe filename in torrent!"
|
then error "found unsafe filename in torrent!"
|
||||||
else f
|
else f
|
||||||
|
@ -365,4 +366,4 @@ torrentContents u = convert
|
||||||
convert l = UrlMulti $ map mkmulti (zip l [1..])
|
convert l = UrlMulti $ map mkmulti (zip l [1..])
|
||||||
|
|
||||||
mkmulti ((fn, sz), n) =
|
mkmulti ((fn, sz), n) =
|
||||||
(torrentUrlWithNum u n, Just sz, mkSafeFilePath fn)
|
(torrentUrlWithNum u n, Just sz, mkSafeFilePath $ joinPath $ drop 1 $ splitPath fn)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue