diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-06-09 20:54:01 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-06-09 20:54:01 -0700 |
commit | 2a110811cfac88891375007db42de6e48ae83e3d (patch) | |
tree | 1a87f4c9e0385a75742b28e4d7ad447742b23f72 /git-access.c | |
parent | 0eb6dc43323a7c4bbcc4801cfd46af3c00948fdc (diff) | |
download | subsurface-2a110811cfac88891375007db42de6e48ae83e3d.tar.gz |
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 <dirk@hohndel.org>
Diffstat (limited to 'git-access.c')
-rw-r--r-- | git-access.c | 15 |
1 files changed, 10 insertions, 5 deletions
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); |