{"thread":{"id":"23259","subject":"[PATCH] remote-curl: Add sanity check for url","startedAt":"2010-03-30T20:08:42Z","lastAt":"2010-03-31T02:43:08Z","messageCount":3,"participants":["Ramkumar Ramachandra","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"138210","messageId":"f3271551003301308y683173f6y6a4fadb01b791049@mail.gmail.com","threadId":"23259","inReplyTo":null,"subject":"[PATCH] remote-curl: Add sanity check for url","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-03-30T20:08:42Z","receivedAt":"2010-03-30T20:08:42Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Previously, `git remote-http foo` and subsquent commands would try to\nwork on a HTML page. This patch fixes the bug by making one assumption\nabout the URL handled by libcurl: it must contain the string \"://\"\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n remote-curl.c |    3 +++\n 1 files changed, 3 insertions(+), 0 deletions(-)\n\ndiff --git a/remote-curl.c b/remote-curl.c\nindex b76bfcb..9320897 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -112,6 +112,9 @@ static struct discovery* discover_refs(const char *service)\n \t}\n \trefs_url = strbuf_detach(&buffer, NULL);\n\n+\t/* sanity check: does this look like a url expected by libcurl? */\n+\tif (!strstr(url, \"://\"))\n+\t\tdie(\"%s is not a url supported by this remote helper\", url);\n \thttp_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);\n\n \t/* try again with \"plain\" url (no ? or & appended) */\n-- \n1.7.0.3\n"},{"id":"138237","messageId":"7voci5qspr.fsf@alter.siamese.dyndns.org","threadId":"23259","inReplyTo":"f3271551003301308y683173f6y6a4fadb01b791049@mail.gmail.com","subject":"Re: [PATCH] remote-curl: Add sanity check for url","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-03-30T23:45:36Z","receivedAt":"2010-03-30T23:45:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramkumar Ramachandra <artagnon@gmail.com> writes:\n\n> Previously, `git remote-http foo` and subsquent commands would try to\n> work on a HTML page. This patch fixes the bug by making one assumption\n> about the URL handled by libcurl: it must contain the string \"://\"\n\nI may be being slow but I do not see the point of this patch.\n\nI thought that remote-foo is never invoked directly from a command line\nwith random arguments, and fetch/push frontends make the decision based on\nthe shape of the \"URL\" (or whatever data used to reach the remote end)\nwhich helper to run.\n\nI do not think your patch would _break_ anything, but my question is more\nabout the reason why we would want a duplicated check here.\n"},{"id":"138250","messageId":"u2tf3271551003301943sf703e66fz4274135efd991430@mail.gmail.com","threadId":"23259","inReplyTo":"7voci5qspr.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] remote-curl: Add sanity check for url","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-03-31T02:43:08Z","receivedAt":"2010-03-31T02:43:08Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi,\n\n> I may be being slow but I do not see the point of this patch.\n\nAgreed, it's not a bug that any end-user would normally bump into. I\nbumped into this myself when I assumed that the remote `foo` exists,\nand invoked `git-remote-http foo`. Since remote_get() transparently\ncreates a remote when one does not exist, remote-curl doesn't know if\nthe remote `foo` ever really exists. Going off to fetch a HTML page\nwhen an expected remote doesn't exist is really ugly, so I thought I'd\nprepare this patch. Plus, it doesn't hurt to make sure that the remote\nhelper conforms to the documentation- useful when a developer is\ncalling it independently.\n\n-- Ram\n"}]}