{"thread":{"id":"25693","subject":"URL-escape the '@' sign in username/password","startedAt":"2010-11-10T01:33:09Z","lastAt":"2010-11-10T16:07:57Z","messageCount":2,"participants":["Gabriel Corona","Matthieu Moy"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"155559","messageId":"4CD9F655.8030908@enst-bretagne.fr","threadId":"25693","inReplyTo":null,"subject":"URL-escape the '@' sign in username/password","fromName":"Gabriel Corona","fromEmail":"gabriel.corona@enst-bretagne.fr","sentAt":"2010-11-10T01:33:09Z","receivedAt":"2010-11-10T01:33:09Z","isPatch":false,"sender":{"key":"gabriel.corona@enst-bretagne.fr","avatar":null},"body":"Hello,\n\nI've been trying to use git with a http/webdav repository with an \nusername containing a '@' character (foobar@host). The git FAQ [1] \nsuggests escaping the '@' character with percent encoding. However, the \nusername and password of the URI are not unescaped and the username \nfoobar%400host is sent to the web server.\n\n$ #Launch a dummy web server\n$ webfsd -4 -r ~/bidouilles/temp/empty/ -L- -F -bfoobar@host:secret \n-p8000 -i 127.0.0.1 &\n\n$ git clone http://foobar%40host:secret@127.0.0.1:8000/\nCloning into 8000...\nfatal: Authentication failed\n\nCompare with:\n\n$ git clone http://127.0.0.1:8000/\nCloning into 8000...\nUsername: foobar@host\nPassword: secret\nfatal: http://127.0.0.1:8000/info/refs not found: did you run git \nupdate-server-info on the server?\n\n[1] \nhttps://git.wiki.kernel.org/index.php/GitFaq#My_username_contains_a_.27.40.27.2C_I_can.27t_clone_through_HTTP.2FHTTPS\n\ndiff --git a/http.c b/http.c\nindex 0a5011f..c4d18a9 100644\n--- a/http.c\n+++ b/http.c\n@@ -297,7 +297,7 @@ static CURL *get_curl_handle(void)\n\n  static void http_auth_init(const char *url)\n  {\n-       char *at, *colon, *cp, *slash;\n+       char *at, *colon, *cp, *slash, *temp;\n         int len;\n\n         cp = strstr(url, \"://\");\n@@ -322,16 +322,25 @@ static void http_auth_init(const char *url)\n                 user_name = xmalloc(len + 1);\n                 memcpy(user_name, cp, len);\n                 user_name[len] = '\\0';\n+               temp = url_decode(user_name);\n+               free(user_name);\n+               user_name = temp;\n                 user_pass = NULL;\n         } else {\n                 len = colon - cp;\n                 user_name = xmalloc(len + 1);\n                 memcpy(user_name, cp, len);\n                 user_name[len] = '\\0';\n+               temp = url_decode(user_name);\n+               free(user_name);\n+               user_name = temp;\n                 len = at - (colon + 1);\n                 user_pass = xmalloc(len + 1);\n                 memcpy(user_pass, colon + 1, len);\n                 user_pass[len] = '\\0';\n+               temp = url_decode(user_pass);\n+               free(user_pass);\n+               user_pass = temp;\n         }\n  }\n\n-- \nGabriel\n"},{"id":"155596","messageId":"vpqpqudw49u.fsf@bauges.imag.fr","threadId":"25693","inReplyTo":"4CD9F655.8030908@enst-bretagne.fr","subject":"Re: URL-escape the '@' sign in username/password","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2010-11-10T16:07:57Z","receivedAt":"2010-11-10T16:07:57Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Gabriel Corona <gabriel.corona@enst-bretagne.fr> writes:\n\n> Hello,\n>\n> I've been trying to use git with a http/webdav repository with an\n> username containing a '@' character (foobar@host). The git FAQ [1]\n> suggests escaping the '@' character with percent encoding.\n\nYes, I'm the one to blame for this: I wrote the FAQ entry trying to\nhelp someone on the list, but I didn't have a webserver to actually do\nthe test.\n\n> diff --git a/http.c b/http.c\n> index 0a5011f..c4d18a9 100644\n> --- a/http.c\n> +++ b/http.c\n\nThe patch sounds good. Can you resend it properly (i.e. use git\nformat-patch and/or git send-email, read about signed-off-by in\nDocumentation/SubmittingPatches, ...) ?\n\nThanks in advance,\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}