From 0d2ac184b569a9dff770fbf678c3f54818609e97 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 14 Jan 2013 12:54:29 -0400 Subject: [PATCH] webapp: Avoid illegal characters in hostname when creating S3 or Glacier remote. --- Assistant/WebApp/Configurators/AWS.hs | 9 ++++++++- debian/changelog | 2 ++ ...ository_with_an_invalid_name_throws_an_exception.mdwn | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Assistant/WebApp/Configurators/AWS.hs b/Assistant/WebApp/Configurators/AWS.hs index 461f401f4e..49ae1347a0 100644 --- a/Assistant/WebApp/Configurators/AWS.hs +++ b/Assistant/WebApp/Configurators/AWS.hs @@ -25,6 +25,7 @@ import Logs.PreferredContent import qualified Data.Text as T import qualified Data.Map as M +import Data.Char awsConfigurator :: Widget -> Handler RepHtml awsConfigurator = page "Add an Amazon repository" (Just Configuration) @@ -175,8 +176,14 @@ makeAWSRemote remotetype (AWSCreds ak sk) name setup config = do remotename <- runAnnex name $ fromRepo $ uniqueRemoteName name 0 liftIO $ AWS.setCredsEnv (T.unpack ak, T.unpack sk) r <- liftAssistant $ liftAnnex $ addRemote $ do - makeSpecialRemote name remotetype config + makeSpecialRemote hostname remotetype config return remotename setup r liftAssistant $ syncNewRemote r redirect $ EditNewCloudRepositoryR $ Remote.uuid r + where + {- AWS services use the remote name as the basis for a host + - name, so filter it to contain valid characters. -} + hostname = case filter isAlphaNum name of + [] -> "aws" + n -> n diff --git a/debian/changelog b/debian/changelog index 8f0384bf0d..249164e397 100644 --- a/debian/changelog +++ b/debian/changelog @@ -17,6 +17,8 @@ git-annex (3.20130108) UNRELEASED; urgency=low * In direct mode, files with the same key are no longer hardlinked, as that would cause a surprising behavior if modifying one, where the other would also change. + * webapp: Avoid illegal characters in hostname when creating S3 or + Glacier remote. -- Joey Hess Tue, 08 Jan 2013 12:37:38 -0400 diff --git a/doc/bugs/Creating_an_S3_repository_with_an_invalid_name_throws_an_exception.mdwn b/doc/bugs/Creating_an_S3_repository_with_an_invalid_name_throws_an_exception.mdwn index 4cb5df545f..48b30ecebd 100644 --- a/doc/bugs/Creating_an_S3_repository_with_an_invalid_name_throws_an_exception.mdwn +++ b/doc/bugs/Creating_an_S3_repository_with_an_invalid_name_throws_an_exception.mdwn @@ -15,3 +15,4 @@ What version of git-annex are you using? On what operating system? Please provide any additional information below. +> [[done]], the name will now be sanitized. --[[Joey]]