diff options
-rw-r--r-- | Backend/SHA.hs | 18 | ||||
-rw-r--r-- | debian/changelog | 4 |
2 files changed, 16 insertions, 6 deletions
diff --git a/Backend/SHA.hs b/Backend/SHA.hs index 1a278068e..34faa4922 100644 --- a/Backend/SHA.hs +++ b/Backend/SHA.hs @@ -17,6 +17,7 @@ import qualified Build.SysConfig as SysConfig import Data.Digest.Pure.SHA import qualified Data.ByteString.Lazy as L import System.Process +import Data.Char type SHASize = Int @@ -124,10 +125,8 @@ selectExtension f where es = filter (not . null) $ reverse $ take 2 $ takeWhile shortenough $ - reverse $ split "." $ takeExtensions f - shortenough e - | '\n' `elem` e = False -- newline in extension?! - | otherwise = length e <= 4 -- long enough for "jpeg" + reverse $ split "." $ filter validExtension $ takeExtensions f + shortenough e = length e <= 4 -- long enough for "jpeg" {- A key's checksum is checked during fsck. -} checkKeyChecksum :: SHASize -> Key -> FilePath -> Annex Bool @@ -152,5 +151,14 @@ checkKeyChecksum size key file = do keySha :: Key -> String keySha key = dropExtensions (keyName key) +validExtension :: Char -> Bool +validExtension c + | isAlphaNum c = True + | c == '.' = True + | otherwise = False + +{- Upgrade keys that have the \ prefix on their sha due to a bug, or + - that contain non-alphanumeric characters in their extension. -} needsUpgrade :: Key -> Bool -needsUpgrade key = "\\" `isPrefixOf` keySha key +needsUpgrade key = "\\" `isPrefixOf` keySha key || + any (not . validExtension) (takeExtensions $ keyName key) diff --git a/debian/changelog b/debian/changelog index e390adf27..30921e2f8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,7 +14,9 @@ git-annex (3.20121212) UNRELEASED; urgency=low when the filename contains \ or a newline. Closes: #696384 * fsck: Still accept checksums with a leading \ as valid, now that above bug is fixed. - * migrate: Remove leading \ in checksums. + * SHA*E backends: Exclude non-alphanumeric characters from extensions. + * migrate: Remove leading \ in SHA* checksums, and non-alphanumerics + from extensions of SHA*E keys. -- Joey Hess <joeyh@debian.org> Thu, 13 Dec 2012 14:06:43 -0400 |