aboutsummaryrefslogtreecommitdiff
path: root/Backend
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-05-27 13:14:51 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-05-27 13:14:51 -0400
commit38bd7ca3cce455c20edcee656c706939087c6a69 (patch)
tree852256db56777c1511d093f051a04961cab66380 /Backend
parent83211d99a949e91698eb30ad9fffff64c2b3eb83 (diff)
Improve SHA*E extension extraction code.
Filter out over-long "extensions" before stripping out non-alphanumerics from them, so that eg "foo.ba__________r" is not considered a .bar extension.
Diffstat (limited to 'Backend')
-rw-r--r--Backend/Hash.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/Backend/Hash.hs b/Backend/Hash.hs
index fd51d87ce..ba8d4bc64 100644
--- a/Backend/Hash.hs
+++ b/Backend/Hash.hs
@@ -101,8 +101,9 @@ selectExtension f
| otherwise = intercalate "." ("":es)
where
es = filter (not . null) $ reverse $
- take 2 $ takeWhile shortenough $
- reverse $ split "." $ filter validInExtension $ takeExtensions f
+ take 2 $ map (filter validInExtension) $
+ takeWhile shortenough $
+ reverse $ split "." $ takeExtensions f
shortenough e = length e <= 4 -- long enough for "jpeg"
{- A key's checksum is checked during fsck. -}