* URL-escape the '@' sign in username/password
@ 2010-11-10 1:33 Gabriel Corona
2010-11-10 16:07 ` Matthieu Moy
0 siblings, 1 reply; 2+ messages in thread
From: Gabriel Corona @ 2010-11-10 1:33 UTC (permalink / raw)
To: git
Hello,
I've been trying to use git with a http/webdav repository with an
username containing a '@' character (foobar@host). The git FAQ [1]
suggests escaping the '@' character with percent encoding. However, the
username and password of the URI are not unescaped and the username
foobar%400host is sent to the web server.
$ #Launch a dummy web server
$ webfsd -4 -r ~/bidouilles/temp/empty/ -L- -F -bfoobar@host:secret
-p8000 -i 127.0.0.1 &
$ git clone http://foobar%40host:secret@127.0.0.1:8000/
Cloning into 8000...
fatal: Authentication failed
Compare with:
$ git clone http://127.0.0.1:8000/
Cloning into 8000...
Username: foobar@host
Password: secret
fatal: http://127.0.0.1:8000/info/refs not found: did you run git
update-server-info on the server?
[1]
https://git.wiki.kernel.org/index.php/GitFaq#My_username_contains_a_.27.40.27.2C_I_can.27t_clone_through_HTTP.2FHTTPS
diff --git a/http.c b/http.c
index 0a5011f..c4d18a9 100644
--- a/http.c
+++ b/http.c
@@ -297,7 +297,7 @@ static CURL *get_curl_handle(void)
static void http_auth_init(const char *url)
{
- char *at, *colon, *cp, *slash;
+ char *at, *colon, *cp, *slash, *temp;
int len;
cp = strstr(url, "://");
@@ -322,16 +322,25 @@ static void http_auth_init(const char *url)
user_name = xmalloc(len + 1);
memcpy(user_name, cp, len);
user_name[len] = '\0';
+ temp = url_decode(user_name);
+ free(user_name);
+ user_name = temp;
user_pass = NULL;
} else {
len = colon - cp;
user_name = xmalloc(len + 1);
memcpy(user_name, cp, len);
user_name[len] = '\0';
+ temp = url_decode(user_name);
+ free(user_name);
+ user_name = temp;
len = at - (colon + 1);
user_pass = xmalloc(len + 1);
memcpy(user_pass, colon + 1, len);
user_pass[len] = '\0';
+ temp = url_decode(user_pass);
+ free(user_pass);
+ user_pass = temp;
}
}
--
Gabriel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: URL-escape the '@' sign in username/password
2010-11-10 1:33 URL-escape the '@' sign in username/password Gabriel Corona
@ 2010-11-10 16:07 ` Matthieu Moy
0 siblings, 0 replies; 2+ messages in thread
From: Matthieu Moy @ 2010-11-10 16:07 UTC (permalink / raw)
To: Gabriel Corona; +Cc: git
Gabriel Corona <gabriel.corona@enst-bretagne.fr> writes:
> Hello,
>
> I've been trying to use git with a http/webdav repository with an
> username containing a '@' character (foobar@host). The git FAQ [1]
> suggests escaping the '@' character with percent encoding.
Yes, I'm the one to blame for this: I wrote the FAQ entry trying to
help someone on the list, but I didn't have a webserver to actually do
the test.
> diff --git a/http.c b/http.c
> index 0a5011f..c4d18a9 100644
> --- a/http.c
> +++ b/http.c
The patch sounds good. Can you resend it properly (i.e. use git
format-patch and/or git send-email, read about signed-off-by in
Documentation/SubmittingPatches, ...) ?
Thanks in advance,
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-10 16:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-10 1:33 URL-escape the '@' sign in username/password Gabriel Corona
2010-11-10 16:07 ` Matthieu Moy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).