diff options
-rw-r--r-- | Backend.hs | 8 | ||||
-rw-r--r-- | Backend/SHA.hs | 10 | ||||
-rw-r--r-- | debian/changelog | 1 | ||||
-rw-r--r-- | doc/bugs/bad_behaviour_with_file_names_with_newline_in_them.mdwn | 2 |
4 files changed, 16 insertions, 5 deletions
diff --git a/Backend.hs b/Backend.hs index f7990c22c..136c2eb7a 100644 --- a/Backend.hs +++ b/Backend.hs @@ -64,7 +64,13 @@ genKey' (b:bs) file = do r <- (B.getKey b) file case r of Nothing -> genKey' bs file - Just k -> return $ Just (k, b) + Just k -> return $ Just (makesane k, b) + where + -- keyNames should not contain newline characters. + makesane k = k { keyName = map fixbadchar (keyName k) } + fixbadchar c + | c == '\n' = '_' + | otherwise = c {- Looks up the key and backend corresponding to an annexed file, - by examining what the file symlinks to. -} diff --git a/Backend/SHA.hs b/Backend/SHA.hs index 2ae0cfcf4..7935b6d26 100644 --- a/Backend/SHA.hs +++ b/Backend/SHA.hs @@ -90,10 +90,12 @@ keyValueE size file = keyValue size file >>= maybe (return Nothing) addE , keyBackendName = shaNameE size } naiveextension = takeExtension file - extension = - if length naiveextension > 6 - then "" -- probably not really an extension - else naiveextension + extension + -- long or newline containing extensions are + -- probably not really an extension + | length naiveextension > 6 || + '\n' `elem` naiveextension = "" + | otherwise = naiveextension {- A key's checksum is checked during fsck. -} checkKeyChecksum :: SHASize -> Key -> Annex Bool diff --git a/debian/changelog b/debian/changelog index 7feb8f8ca..a4d3a6492 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ git-annex (3.20111204) UNRELEASED; urgency=low * map: Fix a failure to detect a loop when both repositories are local and refer to each other with relative paths. + * Prevent key names from containing newlines. -- Joey Hess <joeyh@debian.org> Sun, 04 Dec 2011 12:22:37 -0400 diff --git a/doc/bugs/bad_behaviour_with_file_names_with_newline_in_them.mdwn b/doc/bugs/bad_behaviour_with_file_names_with_newline_in_them.mdwn index 5673d8060..530a8da5d 100644 --- a/doc/bugs/bad_behaviour_with_file_names_with_newline_in_them.mdwn +++ b/doc/bugs/bad_behaviour_with_file_names_with_newline_in_them.mdwn @@ -1,3 +1,5 @@ Found this out the hard way. See the comment in the below post for what happens. [[/forum/git_annex_add_crash_and_subsequent_recovery/]] + +> [[fixed|done]] --[[Joey]] |