{"thread":{"id":"21091","subject":"clone from url with email address as username?(escaping @ symbol)","startedAt":"2009-09-29T14:20:34Z","lastAt":"2009-09-29T20:47:35Z","messageCount":15,"participants":["Ben Bennett","Sverre Rabbelier","Matthieu Moy","Daniel Stenberg"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"123992","messageId":"970bc7c80909290720i1c5566fer1c1a3db744edc609@mail.gmail.com","threadId":"21091","inReplyTo":null,"subject":"clone from url with email address as username?(escaping @ symbol)","fromName":"Ben Bennett","fromEmail":"benbennett@gmail.com","sentAt":"2009-09-29T14:20:34Z","receivedAt":"2009-09-29T14:20:34Z","isPatch":false,"sender":{"key":"benbennett@gmail.com","avatar":null},"body":"Is there any escape sequence for the @ symbol when cloning?\n\n\nThanks,\nBen\n"},{"id":"123994","messageId":"fabb9a1e0909290725w616c3ea9vcb1d2c53950f7788@mail.gmail.com","threadId":"21091","inReplyTo":"970bc7c80909290720i1c5566fer1c1a3db744edc609@mail.gmail.com","subject":"Re: clone from url with email address as username?(escaping @ symbol)","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2009-09-29T14:25:58Z","receivedAt":"2009-09-29T14:25:58Z","isPatch":false,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Tue, Sep 29, 2009 at 16:20, Ben Bennett <benbennett@gmail.com> wrote:\n> Is there any escape sequence for the @ symbol when cloning?\n\nI thought @ is not allowed to be in an url? What do you need to escape it for?\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"123995","messageId":"vpq1vlp962h.fsf@bauges.imag.fr","threadId":"21091","inReplyTo":"fabb9a1e0909290725w616c3ea9vcb1d2c53950f7788@mail.gmail.com","subject":"Re: clone from url with email address as username?(escaping @ symbol)","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2009-09-29T14:30:30Z","receivedAt":"2009-09-29T14:30:30Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Sverre Rabbelier <srabbelier@gmail.com> writes:\n\n> Heya,\n>\n> On Tue, Sep 29, 2009 at 16:20, Ben Bennett <benbennett@gmail.com> wrote:\n>> Is there any escape sequence for the @ symbol when cloning?\n>\n> I thought @ is not allowed to be in an url? What do you need to\n> escape it for?\n\nIf your username is \"foo@bar.com\", then the clone URL might well be\n\nssh://foo@bar.com@server.com/path/to/repo\n\nThe question is which @ is the login/server separator, and which one\nis included in the login. A quick test with\n\ngit clone ssh://foo@bar.com@localhost/path/to/repo\n\nshows me that Git does the right thing, i.e. uses \"foo@bar.com\" as the\nlogin, without the need to escape it.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"123996","messageId":"fabb9a1e0909290732h5119170ew133d906b67e49f99@mail.gmail.com","threadId":"21091","inReplyTo":"vpq1vlp962h.fsf@bauges.imag.fr","subject":"Re: clone from url with email address as username?(escaping @ symbol)","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2009-09-29T14:32:58Z","receivedAt":"2009-09-29T14:32:58Z","isPatch":false,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Tue, Sep 29, 2009 at 16:30, Matthieu Moy\n<Matthieu.Moy@grenoble-inp.fr> wrote:\n> The question is which @ is the login/server separator, and which one\n> is included in the login. A quick test with\n\nI think it only makes sense that this would work, since any @ can\nnever be part of the server name (since it's not an allowed\ncharacter), so I'm still curious why Ben wants to escape his @.\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"124000","messageId":"970bc7c80909290831l59b7fc4at4ec0082f42f3ef87@mail.gmail.com","threadId":"21091","inReplyTo":"fabb9a1e0909290732h5119170ew133d906b67e49f99@mail.gmail.com","subject":"Re: clone from url with email address as username?(escaping @ symbol)","fromName":"Ben Bennett","fromEmail":"benbennett@gmail.com","sentAt":"2009-09-29T15:31:30Z","receivedAt":"2009-09-29T15:31:30Z","isPatch":false,"sender":{"key":"benbennett@gmail.com","avatar":null},"body":"I am attempting to do a https clone. The username is an email address\nbut when I do a clone here is what happens.\n\nHere is what I get , I might be messing up the clone command . btw ,\nif i leave switch it to ssh , yes it does resolve the url correctly.\n\ngit clone https://benjamin.j.bennett@fooserver.com@fooserver.com/git_repos/main-code.git/\ntest\nInitialized empty Git repository in /home/benjamin/planning_workspace/test/.git/\nPassword:\nerror: Couldn't resolve host 'fooserver.com@fooserver.com' while\naccessing https://benjamin.j.bennett@fooserver.com@myfooserver.com/git_repos/main-code.git//info/refs\n\nOn Tue, Sep 29, 2009 at 9:32 AM, Sverre Rabbelier <srabbelier@gmail.com> wrote:\n> Heya,\n>\n> On Tue, Sep 29, 2009 at 16:30, Matthieu Moy\n> <Matthieu.Moy@grenoble-inp.fr> wrote:\n>> The question is which @ is the login/server separator, and which one\n>> is included in the login. A quick test with\n>\n> I think it only makes sense that this would work, since any @ can\n> never be part of the server name (since it's not an allowed\n> character), so I'm still curious why Ben wants to escape his @.\n>\n> --\n> Cheers,\n>\n> Sverre Rabbelier\n>\n"},{"id":"124005","messageId":"vpq63b1u1p6.fsf@bauges.imag.fr","threadId":"21091","inReplyTo":"970bc7c80909290831l59b7fc4at4ec0082f42f3ef87@mail.gmail.com","subject":"Re: clone from url with email address as username?(escaping @ symbol)","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2009-09-29T16:59:17Z","receivedAt":"2009-09-29T16:59:17Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Ben Bennett <benbennett@gmail.com> writes:\n\n> I am attempting to do a https clone. The username is an email address\n> but when I do a clone here is what happens.\n\nHmm, right, it works with ssh, but not http.\n\nI tried a quick fix like this:\n\ndiff --git a/http.c b/http.c\nindex 23b2a19..361a6be 100644\n--- a/http.c\n+++ b/http.c\n@@ -281,9 +281,10 @@ static void http_auth_init(const char *url)\n         * \"proto://<host>/...\"?\n         */\n        cp += 3;\n-       at = strchr(cp, '@');\n        colon = strchr(cp, ':');\n        slash = strchrnul(cp, '/');\n+       for(at = slash-1; *at != '@' && *at != '/'; at--)\n+               continue;\n        if (!at || slash <= at)\n                return; /* No credentials */\n        if (!colon || at <= colon) {\n\nUnfortunately, it seems the complete URL is passed to curl, and curl\nis the one doing it wrong. Indeed:\n\n$ curl -v https://user@email.com@server.com/path/                                          \n* getaddrinfo(3) failed for email.com@server.com:443\n* Couldn't resolve host 'email.com@server.com'\n* Closing connection #0\ncurl: (6) Couldn't resolve host 'email.com@server.com'\n\nNow for the good news:\n\nhttp://curl.haxx.se/mail/lib-2006-02/0134.html\nhttp://sourceforge.net/tracker/index.php?func=detail&aid=2826621&group_id=976&atid=100976\n\nIn short, you have to use %40 to escape the @, and curl does it this\nway because the RFC doesn't allow @ in usernames.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"124004","messageId":"vpqws3hsmqh.fsf@bauges.imag.fr","threadId":"21091","inReplyTo":"vpq63b1u1p6.fsf@bauges.imag.fr","subject":"Re: clone from url with email address as username?(escaping @ symbol)","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2009-09-29T17:07:50Z","receivedAt":"2009-09-29T17:07:50Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> In short, you have to use %40 to escape the @, and curl does it this\n> way because the RFC doesn't allow @ in usernames.\n\nI've added a FAQ on the wiki. Feel free to improve:\n\nhttp://git.or.cz/gitwiki/GitFaq#Myusernamecontainsa.27.40.27.2CIcan.27tclonethroughHTTP.2BAC8-HTTPS\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"124007","messageId":"alpine.DEB.2.00.0909291946520.23903@tvnag.unkk.fr","threadId":"21091","inReplyTo":"vpq63b1u1p6.fsf@bauges.imag.fr","subject":"Re: clone from url with email address as username?(escaping @ symbol)","fromName":"Daniel Stenberg","fromEmail":"daniel@haxx.se","sentAt":"2009-09-29T17:48:57Z","receivedAt":"2009-09-29T17:48:57Z","isPatch":false,"sender":{"key":"daniel@haxx.se","avatar":"https://gravatar.com/avatar/69fdca87edd17cee21ca2e79fc2ff671d644603c3dc27167430f3cd3dbab7ba8?d=mp&s=160"},"body":"On Tue, 29 Sep 2009, Matthieu Moy wrote:\n\n> Unfortunately, it seems the complete URL is passed to curl, and curl\n> is the one doing it wrong. Indeed:\n>\n> $ curl -v https://user@email.com@server.com/path/\n> * getaddrinfo(3) failed for email.com@server.com:443\n\nThis is not exactly curl \"doing it wrong\". This is a user passing in something \nthat isn't a URL to the command that asks for a URL to work on. The user part \ncannot legally have a '@' letter in a URL, you must encode it.\n\n> In short, you have to use %40 to escape the @, and curl does it this way \n> because the RFC doesn't allow @ in usernames.\n\nExactly. So curl is not \"wrong\", it just can't work around this user-error.\n\n-- \n\n  / daniel.haxx.se\n"},{"id":"124006","messageId":"970bc7c80909291051q5dff9209u650cee4f84d92fae@mail.gmail.com","threadId":"21091","inReplyTo":"vpq63b1u1p6.fsf@bauges.imag.fr","subject":"Re: clone from url with email address as username?(escaping @ symbol)","fromName":"Ben Bennett","fromEmail":"benbennett@gmail.com","sentAt":"2009-09-29T17:51:41Z","receivedAt":"2009-09-29T17:51:41Z","isPatch":false,"sender":{"key":"benbennett@gmail.com","avatar":null},"body":"Is it escaping the %40 when passed down? I am getting an error 401  ,\nand checking the server logs , it is passing the %40 to the server in\nthe username.\nRunning curl from command line , I can connect, but through git , the\nusername is getting mangled or I have something screwed up.\n I will look at http.c tonight after work, to see if I am messing something up.\n\nThanks,\nBen\n\n\nOn Tue, Sep 29, 2009 at 11:59 AM, Matthieu Moy\n<Matthieu.Moy@grenoble-inp.fr> wrote:\n> Ben Bennett <benbennett@gmail.com> writes:\n>\n>> I am attempting to do a https clone. The username is an email address\n>> but when I do a clone here is what happens.\n>\n> Hmm, right, it works with ssh, but not http.\n>\n> I tried a quick fix like this:\n>\n> diff --git a/http.c b/http.c\n> index 23b2a19..361a6be 100644\n> --- a/http.c\n> +++ b/http.c\n> @@ -281,9 +281,10 @@ static void http_auth_init(const char *url)\n>         * \"proto://<host>/...\"?\n>         */\n>        cp += 3;\n> -       at = strchr(cp, '@');\n>        colon = strchr(cp, ':');\n>        slash = strchrnul(cp, '/');\n> +       for(at = slash-1; *at != '@' && *at != '/'; at--)\n> +               continue;\n>        if (!at || slash <= at)\n>                return; /* No credentials */\n>        if (!colon || at <= colon) {\n>\n> Unfortunately, it seems the complete URL is passed to curl, and curl\n> is the one doing it wrong. Indeed:\n>\n> $ curl -v https://user@email.com@server.com/path/\n> * getaddrinfo(3) failed for email.com@server.com:443\n> * Couldn't resolve host 'email.com@server.com'\n> * Closing connection #0\n> curl: (6) Couldn't resolve host 'email.com@server.com'\n>\n> Now for the good news:\n>\n> http://curl.haxx.se/mail/lib-2006-02/0134.html\n> http://sourceforge.net/tracker/index.php?func=detail&aid=2826621&group_id=976&atid=100976\n>\n> In short, you have to use %40 to escape the @, and curl does it this\n> way because the RFC doesn't allow @ in usernames.\n>\n> --\n> Matthieu Moy\n> http://www-verimag.imag.fr/~moy/\n>\n"},{"id":"124008","messageId":"vpq1vlpr5le.fsf@bauges.imag.fr","threadId":"21091","inReplyTo":"970bc7c80909291051q5dff9209u650cee4f84d92fae@mail.gmail.com","subject":"Re: clone from url with email address as username?(escaping @ symbol)","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2009-09-29T18:03:25Z","receivedAt":"2009-09-29T18:03:25Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Ben Bennett <benbennett@gmail.com> writes:\n\n> Is it escaping the %40 when passed down? I am getting an error 401  ,\n> and checking the server logs , it is passing the %40 to the server in\n> the username.\n> Running curl from command line , I can connect, but through git , the\n> username is getting mangled or I have something screwed up.\n\nOK, so it seems Git should be fixed to unescape this %40 somewhere,\nmost likely in http_auth_init in http.c, in addition to by fix below.\nhttp://curl.haxx.se/libcurl/c/curl_easy_unescape.html might help. I've\nconsumed by Git time budget for now, so if anyone else can have a\nlook ...\n\n>> --- a/http.c\n>> +++ b/http.c\n>> @@ -281,9 +281,10 @@ static void http_auth_init(const char *url)\n>>         * \"proto://<host>/...\"?\n>>         */\n>>        cp += 3;\n>> -       at = strchr(cp, '@');\n>>        colon = strchr(cp, ':');\n>>        slash = strchrnul(cp, '/');\n>> +       for(at = slash-1; *at != '@' && *at != '/'; at--)\n>> +               continue;\n>>        if (!at || slash <= at)\n>>                return; /* No credentials */\n>>        if (!colon || at <= colon) {\n>>\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"124009","messageId":"vpqws3hpqr1.fsf@bauges.imag.fr","threadId":"21091","inReplyTo":"alpine.DEB.2.00.0909291946520.23903@tvnag.unkk.fr","subject":"Re: clone from url with email address as username?(escaping @ symbol)","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2009-09-29T18:09:22Z","receivedAt":"2009-09-29T18:09:22Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Daniel Stenberg <daniel@haxx.se> writes:\n\n> On Tue, 29 Sep 2009, Matthieu Moy wrote:\n>\n>> Unfortunately, it seems the complete URL is passed to curl, and curl\n>> is the one doing it wrong. Indeed:\n>>\n>> $ curl -v https://user@email.com@server.com/path/\n>> * getaddrinfo(3) failed for email.com@server.com:443\n>\n> This is not exactly curl \"doing it wrong\". This is a user passing in\n> something that isn't a URL to the command that asks for a URL to work\n> on. The user part cannot legally have a '@' letter in a URL, you must\n> encode it.\n>\n>> In short, you have to use %40 to escape the @, and curl does it this\n>> way because the RFC doesn't allow @ in usernames.\n>\n> Exactly. So curl is not \"wrong\", it just can't work around this user-error.\n\nIt may not want work around user-errors, but you can hardly say that\nit _can't_. Many tools do in this case, Firefox is one of them. And\nanyway, trying to connect to email.com@server.com is probably the\nworst thing it can do.\n\nAt least, it could warn about two @ in the URL and say it can't\nhandle it ...\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"124010","messageId":"vpqpr99pqle.fsf@bauges.imag.fr","threadId":"21091","inReplyTo":"vpq1vlpr5le.fsf@bauges.imag.fr","subject":"Re: clone from url with email address as username?(escaping @ symbol)","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2009-09-29T18:12:45Z","receivedAt":"2009-09-29T18:12:45Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> OK, so it seems Git should be fixed to unescape this %40 somewhere,\n> most likely in http_auth_init in http.c, in addition to by fix\n> below.\n\n... err, no not _in addition_ to it, forget this. There's one @ and\ngit finds it correctly.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"124012","messageId":"970bc7c80909291155y492b458fg237c2f9d028af718@mail.gmail.com","threadId":"21091","inReplyTo":"vpqpr99pqle.fsf@bauges.imag.fr","subject":"Re: clone from url with email address as username?(escaping @ symbol)","fromName":"Ben Bennett","fromEmail":"benbennett@gmail.com","sentAt":"2009-09-29T18:55:57Z","receivedAt":"2009-09-29T18:55:57Z","isPatch":false,"sender":{"key":"benbennett@gmail.com","avatar":null},"body":"I will look at it tonight. But my fix would be to automatically escape\nthe @ symbol when  git passes onto curl.\nDon't know if this would work easy or not, but it would be something\nalong the lines of .\n\nhttps://(USERNAME)@(SERVER_ADDR)\n\nThe @ would be  the last index of the @ symbol in the URL.\nThen somekind of function that escape_username_for_curl.\n\n\n\n\nOn Tue, Sep 29, 2009 at 1:12 PM, Matthieu Moy\n<Matthieu.Moy@grenoble-inp.fr> wrote:\n> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n>\n>> OK, so it seems Git should be fixed to unescape this %40 somewhere,\n>> most likely in http_auth_init in http.c, in addition to by fix\n>> below.\n>\n> ... err, no not _in addition_ to it, forget this. There's one @ and\n> git finds it correctly.\n>\n> --\n> Matthieu Moy\n> http://www-verimag.imag.fr/~moy/\n>\n"},{"id":"124015","messageId":"alpine.DEB.2.00.0909292228120.23903@tvnag.unkk.fr","threadId":"21091","inReplyTo":"vpqws3hpqr1.fsf@bauges.imag.fr","subject":"Re: clone from url with email address as username?(escaping @ symbol)","fromName":"Daniel Stenberg","fromEmail":"daniel@haxx.se","sentAt":"2009-09-29T20:38:19Z","receivedAt":"2009-09-29T20:38:19Z","isPatch":false,"sender":{"key":"daniel@haxx.se","avatar":"https://gravatar.com/avatar/69fdca87edd17cee21ca2e79fc2ff671d644603c3dc27167430f3cd3dbab7ba8?d=mp&s=160"},"body":"On Tue, 29 Sep 2009, Matthieu Moy wrote:\n\n>> Exactly. So curl is not \"wrong\", it just can't work around this user-error.\n>\n> It may not want work around user-errors, but you can hardly say that\n> it _can't_.\n\nIt can't work around this error. In theory we could make it GUESS that one of \nthe @-letters are actually supposed to be %40, but I won't. It could also \nguess that @ was accidentally a '2' with alt-gr pressed when using a nordic \nkeyboard layout. Guessing here is crazy.\n\n> Many tools do in this case, Firefox is one of them.\n\nSo what if you had that @ in your password and not in your user name?\n\n> And anyway, trying to connect to email.com@server.com is probably the worst \n> thing it can do.\n\nI understand that you're saying that as a git user and someone who's not into \ncurl and libcurl details, but I'm in the opposite corner mostly and I claim \nthat isn't at all such a bad outcome from that input. curl has that approach \nthrough-out its entire URL parser. It gets what it needs and then uses the \nrest unparsed. That way it is very liberal in what it accepts and it doesn't \nreject bad URLs as long as it only can extract the parts it needs.\n\nIf curl had a strict parser it would of course bluntly reject that URL at \nonce.\n\n> At least, it could warn about two @ in the URL and say it can't handle it\n\nIt could, sure. But curl has no such strict parser so it accepts all sorts of \nvarious violations.\n\nI don't think this is the proper place to discuss what curl (or libcurl) \nshould or shouldn't do with given URLs - but you're most welcome to bring your \nideas and patches to the curl project and we can debate their virtues over \nthere.\n\n-- \n\n  / daniel.haxx.se\n"},{"id":"124016","messageId":"vpqzl8dmqag.fsf@bauges.imag.fr","threadId":"21091","inReplyTo":"alpine.DEB.2.00.0909292228120.23903@tvnag.unkk.fr","subject":"Re: clone from url with email address as username?(escaping @ symbol)","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2009-09-29T20:47:35Z","receivedAt":"2009-09-29T20:47:35Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Daniel Stenberg <daniel@haxx.se> writes:\n\n>> Many tools do in this case, Firefox is one of them.\n>\n> So what if you had that @ in your password and not in your user\n> name?\n\nThen the last @ would still be the separator between the\nlogin/password and the hostname, and looking at the '@' starting from\nthe right hand side would still work.\n\nThe problem is if you have a \":\" in your login or password, _then_ it\nis ambiguous (but by far less common), but the @ is here to split\nsomething that can have a @ in it (login:pass) and something which\ncan't (hostname), so there isn't any ambiguity.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}