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

Re: [PATCH] Do not decode url protocol.

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Jun 23, 2010, 23:54 UTC
Message-ID
<4C229EA0.6010904@lsrfire.ath.cx>
In-Reply-To
<AANLkTinK99krA-16qUO8nWYbZ7w6o632jLTTW5WyaKOk@mail.gmail.com>
Am 22.06.2010 11:25, schrieb Pascal Obry:
Show 33 quoted lines
> Same patch with fixed formatting. Sorry.
> 
> When using the protocol git+ssh:// for example we do not want to
> decode the '+' as a space.
> 
> This fixes a regression introduced in 9d2e942.
> ---
>  url.c |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/url.c b/url.c
> index cd32b92..94a42a5 100644
> --- a/url.c
> +++ b/url.c
> @@ -70,9 +70,18 @@ static int url_decode_char(const char *q)
>  static char *url_decode_internal(const char **query, const char *stop_at)
>  {
>  	const char *q = *query;
> +	const char *first_slash;
>  	struct strbuf out;
> 
>  	strbuf_init(&out, 16);
> +
> +	/* Skip protocol. */
> +	first_slash = strchr(*query, '/');
> +
> +	while (q < first_slash) {
> +		strbuf_addch(&out, *q++);
> +	}
> +
>  	do {
>  		unsigned char c = *q;
> 

The protocol in an URL is followed by a colon and technically a slash doesn't have to be part of it at all. While in practise all URL schemes used by git have two slashes following the colon, it's just as easy to be more correct and search for ':' instead of '/' here.

And you can use strbuf_add() instead of the while loop because you know how many characters to copy.

René
Previous: Pascal ObryNext: Junio C Hamano
Message 5 of 6 in “Do not decode url protocol.”
  1. Do not decode url protocol.Pascal Obry, Jun 22, 2010
  2. Matthieu MoyJun 22, 2010
  3. Matthieu MoyJun 22, 2010
  4. Pascal ObryJun 22, 2010
  5. René ScharfeJun 23, 2010
  6. Junio C HamanoJun 29, 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.