summaryrefslogtreecommitdiff
path: root/src/netops.c
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2013-01-30 18:50:31 -0800
committerBen Straub <bs@github.com>2013-01-30 18:52:47 -0800
commit5f10853e90014ea9929a976f647f2a2d32a2c129 (patch)
tree9e13a60dff6972794b14f03ecda0aa82c6818fc4 /src/netops.c
parent5f9f69d983d7ebc2d9d29cf295e86f32ab12906d (diff)
downloadlibgit2-5f10853e90014ea9929a976f647f2a2d32a2c129.tar.gz
Skip "user@" when finding hostname in url
Diffstat (limited to 'src/netops.c')
-rw-r--r--src/netops.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/netops.c b/src/netops.c
index 59e6bda1e..5623ca9bf 100644
--- a/src/netops.c
+++ b/src/netops.c
@@ -580,10 +580,12 @@ int gitno_select_in(gitno_buffer *buf, long int sec, long int usec)
int gitno_extract_host_and_port(char **host, char **port, const char *url, const char *default_port)
{
- char *colon, *slash, *delim;
+ char *colon, *slash, *at, *delim;
+ const char *start;
colon = strchr(url, ':');
slash = strchr(url, '/');
+ at = strchr(url, '@');
if (slash == NULL) {
giterr_set(GITERR_NET, "Malformed URL: missing /");
@@ -598,7 +600,9 @@ int gitno_extract_host_and_port(char **host, char **port, const char *url, const
GITERR_CHECK_ALLOC(*port);
delim = colon == NULL ? slash : colon;
- *host = git__strndup(url, delim - url);
+ start = at == NULL && at < slash ? url : at+1;
+
+ *host = git__strndup(start, delim - start);
GITERR_CHECK_ALLOC(*host);
return 0;