git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Allow '+', '-' and '.' in remote helper names

From
ILIlari Liusvaara <ilari.liusvaara@elisanet.fi>
Date
Feb 23, 2010, 12:33 UTC
Message-ID
<1266928428-19075-1-git-send-email-ilari.liusvaara@elisanet.fi>

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
Next: Johannes Schindelin
Message 1 of 9 in “Allow '+', '-' and '.' in remote helper names”
  1. Allow '+', '-' and '.' in remote helper namesIlari Liusvaara, Feb 23, 2010
  2. Johannes SchindelinFeb 23, 2010
  3. Sverre RabbelierFeb 23, 2010
  4. Johannes SchindelinFeb 23, 2010
  5. Johannes SixtFeb 23, 2010
  6. Erik Faye-LundFeb 23, 2010
  7. Johannes SchindelinFeb 23, 2010
  8. Paolo BonziniFeb 23, 2010
  9. Gabriel FilionFeb 23, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.