summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-09-29 12:27:43 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-09-29 12:27:43 -0400
commit751f7947483580f17476bd74bc8cb5703f1b926b (patch)
treecddc2e257d2b679a24d1d8c89b536cea5d3e02a6
parent7147b7b8b2a2bdb89e7c4f273f5f52b472c65105 (diff)
sanitize all git remote names
-rw-r--r--Assistant/MakeRemote.hs14
-rw-r--r--doc/bugs/removable_device_configurator_chokes_on_spaces.mdwn2
2 files changed, 11 insertions, 5 deletions
diff --git a/Assistant/MakeRemote.hs b/Assistant/MakeRemote.hs
index 729b5126a..9184cb529 100644
--- a/Assistant/MakeRemote.hs
+++ b/Assistant/MakeRemote.hs
@@ -25,6 +25,7 @@ import Logs.Remote
import qualified Data.Text as T
import qualified Data.Map as M
+import Data.Char
{- Sets up and begins syncing with a new ssh or rsync remote. -}
makeSshRemote :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> Bool -> SshData -> IO ()
@@ -99,14 +100,19 @@ makeRemote basename location a = do
samelocation x = Git.repoLocation x == location
{- Generate an unused name for a remote, adding a number if
- - necessary. -}
+ - necessary.
+ -
+ - Ensures that the returned name is a legal git remote name. -}
uniqueRemoteName :: String -> Int -> Git.Repo -> String
uniqueRemoteName basename n r
| null namecollision = name
- | otherwise = uniqueRemoteName basename (succ n) r
+ | otherwise = uniqueRemoteName legalbasename (succ n) r
where
namecollision = filter samename (Git.remotes r)
samename x = Git.remoteName x == Just name
name
- | n == 0 = basename
- | otherwise = basename ++ show n
+ | n == 0 = legalbasename
+ | otherwise = legalbasename ++ show n
+ legalbasename = filter legal basename
+ legal '_' = True
+ legal c = isAlphaNum c
diff --git a/doc/bugs/removable_device_configurator_chokes_on_spaces.mdwn b/doc/bugs/removable_device_configurator_chokes_on_spaces.mdwn
index d256071f4..e114877ec 100644
--- a/doc/bugs/removable_device_configurator_chokes_on_spaces.mdwn
+++ b/doc/bugs/removable_device_configurator_chokes_on_spaces.mdwn
@@ -15,4 +15,4 @@ The assistant produces an internal server error and subsequently crashes complet
git-annex 3.20120924 from the Debian package in sid on Debian wheezy, amd64.
-
+> Thanks for reporting this, I've fixed it in git. [[done]] --[[Joey]]