git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] remote-curl: Add sanity check for url
@ 2010-03-30 20:08 Ramkumar Ramachandra
  2010-03-30 23:45 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Ramkumar Ramachandra @ 2010-03-30 20:08 UTC (permalink / raw)
  To: Git Mailing List
  Cc: Daniel Barkalow, Junio C Hamano, Tay Ray Chuan, Shawn O. Pearce,
	Sverre Rabbelier

Previously, `git remote-http foo` and subsquent commands would try to
work on a HTML page. This patch fixes the bug by making one assumption
about the URL handled by libcurl: it must contain the string "://"

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 remote-curl.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/remote-curl.c b/remote-curl.c
index b76bfcb..9320897 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -112,6 +112,9 @@ static struct discovery* discover_refs(const char *service)
 	}
 	refs_url = strbuf_detach(&buffer, NULL);

+	/* sanity check: does this look like a url expected by libcurl? */
+	if (!strstr(url, "://"))
+		die("%s is not a url supported by this remote helper", url);
 	http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);

 	/* try again with "plain" url (no ? or & appended) */
-- 
1.7.0.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] remote-curl: Add sanity check for url
  2010-03-30 20:08 [PATCH] remote-curl: Add sanity check for url Ramkumar Ramachandra
@ 2010-03-30 23:45 ` Junio C Hamano
  2010-03-31  2:43   ` Ramkumar Ramachandra
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2010-03-30 23:45 UTC (permalink / raw)
  To: Ramkumar Ramachandra
  Cc: Git Mailing List, Daniel Barkalow, Tay Ray Chuan, Shawn O. Pearce,
	Sverre Rabbelier

Ramkumar Ramachandra <artagnon@gmail.com> writes:

> Previously, `git remote-http foo` and subsquent commands would try to
> work on a HTML page. This patch fixes the bug by making one assumption
> about the URL handled by libcurl: it must contain the string "://"

I may be being slow but I do not see the point of this patch.

I thought that remote-foo is never invoked directly from a command line
with random arguments, and fetch/push frontends make the decision based on
the shape of the "URL" (or whatever data used to reach the remote end)
which helper to run.

I do not think your patch would _break_ anything, but my question is more
about the reason why we would want a duplicated check here.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] remote-curl: Add sanity check for url
  2010-03-30 23:45 ` Junio C Hamano
@ 2010-03-31  2:43   ` Ramkumar Ramachandra
  0 siblings, 0 replies; 3+ messages in thread
From: Ramkumar Ramachandra @ 2010-03-31  2:43 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Git Mailing List, Daniel Barkalow, Tay Ray Chuan, Shawn O. Pearce,
	Sverre Rabbelier

Hi,

> I may be being slow but I do not see the point of this patch.

Agreed, it's not a bug that any end-user would normally bump into. I
bumped into this myself when I assumed that the remote `foo` exists,
and invoked `git-remote-http foo`. Since remote_get() transparently
creates a remote when one does not exist, remote-curl doesn't know if
the remote `foo` ever really exists. Going off to fetch a HTML page
when an expected remote doesn't exist is really ugly, so I thought I'd
prepare this patch. Plus, it doesn't hurt to make sure that the remote
helper conforms to the documentation- useful when a developer is
calling it independently.

-- Ram

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-03-31  2:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-30 20:08 [PATCH] remote-curl: Add sanity check for url Ramkumar Ramachandra
2010-03-30 23:45 ` Junio C Hamano
2010-03-31  2:43   ` Ramkumar Ramachandra

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).