git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: Pascal Obry <pascal@obry.net>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] Do not decode url protocol.
Date: Thu, 24 Jun 2010 01:54:08 +0200	[thread overview]
Message-ID: <4C229EA0.6010904@lsrfire.ath.cx> (raw)
In-Reply-To: <AANLkTinK99krA-16qUO8nWYbZ7w6o632jLTTW5WyaKOk@mail.gmail.com>

Am 22.06.2010 11:25, schrieb Pascal Obry:
> 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é

  parent reply	other threads:[~2010-06-23 23:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-22  9:25 [PATCH] Do not decode url protocol Pascal Obry
2010-06-22 11:22 ` Matthieu Moy
2010-06-22 11:34 ` Matthieu Moy
2010-06-22 11:46   ` Pascal Obry
2010-06-23 23:54 ` René Scharfe [this message]
2010-06-29 16:50   ` Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2010-06-22  9:22 Pascal Obry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C229EA0.6010904@lsrfire.ath.cx \
    --to=rene.scharfe@lsrfire.ath.cx \
    --cc=git@vger.kernel.org \
    --cc=pascal@obry.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).