From 480495beb4a3422f006ee529df807a20cc944727 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 6 Dec 2011 13:02:50 -0400 Subject: 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. --- Backend.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Backend.hs') 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. -} -- cgit v1.2.3