From: Jeff King <peff@peff.net>
To: pascal@obry.net
Cc: git list <git@vger.kernel.org>,
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Subject: Re: [PATCH v4] Do not decode url protocol.
Date: Tue, 22 Jun 2010 18:46:04 -0400 [thread overview]
Message-ID: <20100622224603.GA27423@coredump.intra.peff.net> (raw)
In-Reply-To: <4C211A39.2080207@obry.net>
On Tue, Jun 22, 2010 at 10:16:57PM +0200, Pascal Obry wrote:
> When using the protocol git+ssh:// for example we do not want to
> decode the '+' as a space. The url decoding must take place only
> for the server name and parameters.
>
> This fixes a regression introduced in 9d2e942.
Sorry, this is completely my fault. I obviously didn't test with
git+ssh. I looked at adding a new test case, but I don't think there's
an easy way. The only way to trigger it is by using "git+ssh" or
"ssh+git"; any other protocol (real or fake) will be handled by a custom
protocol handler and won't execute this broken code at all.
The patch looks reasonable (and I agree with all of Matthieu's comments
thus far). With respect to the "what if there is no slash" issue
discussed earlier, I prefer to be a bit defensive about possible inputs
in library-ish functions like this. But:
> +
> + /* Skip protocol if present. */
> + if (with_protocol) {
> + first_slash = strchr(*query, '/');
> +
> + while (q < first_slash)
> + strbuf_addch(&out, *q++);
> + }
> +
I think this actually works OK, given that "q < first_slash" will be
false if first_slash is NULL, assuming NULL is all-bytes-zero or some
low number (which is not guaranteed by the standard, but is a pretty
practical assumption these days).
However, you could make things a little more efficient by handing the
whole thing to strbuf at once:
if (with_protocol) {
const char *first_slash = strchr(q, '/');
if (first_slash) {
strbuf_add(&out, q, first_slash - q);
q = first_slash;
}
}
which of course needs first_slash to be checked explicitly. Not that
the efficiency probably matters in practice.
-Peff
next prev parent reply other threads:[~2010-06-22 22:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-22 20:16 [PATCH v4] Do not decode url protocol Pascal Obry
2010-06-22 21:39 ` Matthieu Moy
2010-06-22 22:46 ` Jeff King [this message]
2010-06-23 17:27 ` Junio C Hamano
2010-06-23 17:38 ` Jeff King
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=20100622224603.GA27423@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=Matthieu.Moy@grenoble-inp.fr \
--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).