Prevent key names from containing newlines.
There are several places where it's assumed a key can be written on one line. One is in the format of the .git/annex/unused files. The difficult one is that filenames derived from keys are fed into git cat-file --batch, which has a line based input. (And no -z option.) So, for now it's best to block such keys being created.
This commit is contained in:
parent
cf5353acb4
commit
480495beb4
4 changed files with 16 additions and 5 deletions
|
@ -64,7 +64,13 @@ genKey' (b:bs) file = do
|
||||||
r <- (B.getKey b) file
|
r <- (B.getKey b) file
|
||||||
case r of
|
case r of
|
||||||
Nothing -> genKey' bs file
|
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,
|
{- Looks up the key and backend corresponding to an annexed file,
|
||||||
- by examining what the file symlinks to. -}
|
- by examining what the file symlinks to. -}
|
||||||
|
|
|
@ -90,10 +90,12 @@ keyValueE size file = keyValue size file >>= maybe (return Nothing) addE
|
||||||
, keyBackendName = shaNameE size
|
, keyBackendName = shaNameE size
|
||||||
}
|
}
|
||||||
naiveextension = takeExtension file
|
naiveextension = takeExtension file
|
||||||
extension =
|
extension
|
||||||
if length naiveextension > 6
|
-- long or newline containing extensions are
|
||||||
then "" -- probably not really an extension
|
-- probably not really an extension
|
||||||
else naiveextension
|
| length naiveextension > 6 ||
|
||||||
|
'\n' `elem` naiveextension = ""
|
||||||
|
| otherwise = naiveextension
|
||||||
|
|
||||||
{- A key's checksum is checked during fsck. -}
|
{- A key's checksum is checked during fsck. -}
|
||||||
checkKeyChecksum :: SHASize -> Key -> Annex Bool
|
checkKeyChecksum :: SHASize -> Key -> Annex Bool
|
||||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -2,6 +2,7 @@ git-annex (3.20111204) UNRELEASED; urgency=low
|
||||||
|
|
||||||
* map: Fix a failure to detect a loop when both repositories are local
|
* map: Fix a failure to detect a loop when both repositories are local
|
||||||
and refer to each other with relative paths.
|
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
|
-- Joey Hess <joeyh@debian.org> Sun, 04 Dec 2011 12:22:37 -0400
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
Found this out the hard way. See the comment in the below post for what happens.
|
Found this out the hard way. See the comment in the below post for what happens.
|
||||||
|
|
||||||
[[/forum/git_annex_add_crash_and_subsequent_recovery/]]
|
[[/forum/git_annex_add_crash_and_subsequent_recovery/]]
|
||||||
|
|
||||||
|
> [[fixed|done]] --[[Joey]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue