aboutsummaryrefslogtreecommitdiff
path: root/Backend/Hash.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2018-03-05 11:25:01 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2018-03-05 11:25:01 -0400
commitda3f2ee6994daafe58b890c3fb87ccf5ef61f3f2 (patch)
tree661efe702c741449882fd21e1840dae1b1548253 /Backend/Hash.hs
parentdf575f0db7c945a26735d0944b05c7e989cdfcda (diff)
Improve SHA*E extension extraction code
Do not treat parts of the filename that contain punctuation or other non-alphanumeric characters as extensions. Before, such characters were filtered out. Note that in 38bd7ca3cce455c20edcee656c706939087c6a69 "foo.ba__________r" was munged to ".bar" and so incorrectly treated as an extension. That was fixed by changing the filter order, but not allowing punctuation seems a better fix. This assumes that extensions containing punctuation are rare. "_" seems the most likely character; I used it in ikiwiki "._comment" files. But I can't recall seeing it anywhere else. It certianly seems that no commonly used extensions contain punctuation. If git-annex doesn't treat "._comment" as an extension, it's not likely to break software that expects to see that extension like some software expects to see .epub or .mp3. This commit was sponsored by Jack Hill on Patreon.
Diffstat (limited to 'Backend/Hash.hs')
-rw-r--r--Backend/Hash.hs2
1 files changed, 1 insertions, 1 deletions
diff --git a/Backend/Hash.hs b/Backend/Hash.hs
index da0f7df9b..1d5436823 100644
--- a/Backend/Hash.hs
+++ b/Backend/Hash.hs
@@ -94,7 +94,7 @@ selectExtension f
| otherwise = intercalate "." ("":es)
where
es = filter (not . null) $ reverse $
- take 2 $ map (filter validInExtension) $
+ take 2 $ filter (all validInExtension) $
takeWhile shortenough $
reverse $ splitc '.' $ takeExtensions f
shortenough e = length e <= 4 -- long enough for "jpeg"