From 2a110811cfac88891375007db42de6e48ae83e3d Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 9 Jun 2015 20:54:01 -0700 Subject: Cloud storage: be more careful when trying to determine a user name Since we use the email address (including the '@' sign) as the repository name we have to be more careful when trying to pick an account name from a git URL. Signed-off-by: Dirk Hohndel --- git-access.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'git-access.c') diff --git a/git-access.c b/git-access.c index ca0f3a161..580badd2b 100644 --- a/git-access.c +++ b/git-access.c @@ -250,11 +250,16 @@ static struct git_repository *is_remote_git_repository(char *remote, const char if (!strncmp(remote, "https://", 8)) { char *at = strchr(remote, '@'); if (at) { - /* grab the part between "https://" and "@" as encoded email address - * (that's our username) and move the rest of the URL forward, remembering - * to copy the closing NUL as well */ - prefs.cloud_storage_email_encoded = strndup(remote + 8, at - remote - 8); - memmove(remote + 8, at + 1, strlen(at + 1) + 1); + /* was this the @ that denotes an account? that means it was before the + * first '/' after the https:// - so let's find a '/' after that and compare */ + char *slash = strchr(remote + 8, '/'); + if (slash && slash > at) { + /* grab the part between "https://" and "@" as encoded email address + * (that's our username) and move the rest of the URL forward, remembering + * to copy the closing NUL as well */ + prefs.cloud_storage_email_encoded = strndup(remote + 8, at - remote - 8); + memmove(remote + 8, at + 1, strlen(at + 1) + 1); + } } } localdir = get_local_dir(remote, branch); -- cgit v1.2.3-70-g09d2