git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Allow '+', '-' and '.' in remote helper names
@ 2010-02-23 12:33 Ilari Liusvaara
  2010-02-23 13:03 ` Johannes Schindelin
  2010-02-23 13:48 ` Paolo Bonzini
  0 siblings, 2 replies; 9+ messages in thread
From: Ilari Liusvaara @ 2010-02-23 12:33 UTC (permalink / raw)
  To: git

According to relevant RFCs, in addition to alphanumerics, the following
characters are valid in URL scheme parts: '+', '-' and '.', but
currently only alphanumerics are allowed in remote helper names.

Allow those three characters in remote helper names (both 'foo://' and
'foo::' syntax).

Signed-off-by: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
---
 transport.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/transport.c b/transport.c
index 08e4fa0..00acff1 100644
--- a/transport.c
+++ b/transport.c
@@ -872,6 +872,21 @@ static int is_file(const char *url)
 	return S_ISREG(buf.st_mode);
 }
 
+static int isurlschemechar(int first_flag, int ch)
+{
+	/*
+	 * The set of valid URL schemes, as per STD66 (RFC3986) is
+	 * '[A-Za-z][A-Za-z0-9+.-]*'. But use sightly looser check
+	 * of '[A-Za-z0-9][A-Za-z0-9+.-]*' because earlier version
+	 * of check used '[A-Za-z0-9]+' so not to break any remote
+	 * helpers.
+	 */
+	int alphanumeric, special;
+	alphanumeric = ch > 0 && isalnum(ch);
+	special = ch == '+' || ch == '-' || ch == '.';
+	return alphanumeric || (!first_flag && special);
+}
+
 static int is_url(const char *url)
 {
 	const char *url2, *first_slash;
@@ -896,7 +911,7 @@ static int is_url(const char *url)
 	 */
 	url2 = url;
 	while (url2 < first_slash - 1) {
-		if (!isalnum((unsigned char)*url2))
+		if (!isurlschemechar(url2 == url, (unsigned char)*url2))
 			return 0;
 		url2++;
 	}
@@ -930,7 +945,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
 	if (url) {
 		const char *p = url;
 
-		while (isalnum(*p))
+		while (isurlschemechar(p == url, *p))
 			p++;
 		if (!prefixcmp(p, "::"))
 			helper = xstrndup(url, p - url);
-- 
1.7.0.86.gb35cab

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

end of thread, other threads:[~2010-02-23 17:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-23 12:33 [PATCH] Allow '+', '-' and '.' in remote helper names Ilari Liusvaara
2010-02-23 13:03 ` Johannes Schindelin
2010-02-23 13:07   ` Sverre Rabbelier
2010-02-23 13:51     ` Johannes Schindelin
2010-02-23 13:19   ` Johannes Sixt
2010-02-23 13:32     ` Erik Faye-Lund
2010-02-23 14:42       ` Johannes Schindelin
2010-02-23 13:48 ` Paolo Bonzini
2010-02-23 17:12   ` Gabriel Filion

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