public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Stefan Beller <sbeller@google•com>
Cc: "git\@vger.kernel.org" <git@vger•kernel.org>,
	Johannes Sixt <j6t@kdbg•org>, Jeff King <peff@peff•net>,
	Jens Lehmann <jens.lehmann@web•de>
Subject: Re: [PATCH] submodule: Port resolve_relative_url from shell to C
Date: Fri, 15 Jan 2016 09:37:26 -0800	[thread overview]
Message-ID: <xmqqwpraiw15.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <CAGZ79ka0rxYK7GRSjh13XOsg887EgqYtc5B60z9qU=tAoJGERQ@mail.gmail.com> (Stefan Beller's message of "Wed, 13 Jan 2016 14:47:20 -0800")

Stefan Beller <sbeller@google•com> writes:

> On Wed, Jan 13, 2016 at 2:03 PM, Junio C Hamano <gitster@pobox•com> wrote:
>> Stefan Beller <sbeller@google•com> writes:
>>> +     while (url) {
>>> +             if (starts_with_dot_dot_slash(url)) {
>>> +                     char *rfind;
>>> +                     url += 3;
>>> +
>>> +                     rfind = last_dir_separator(remoteurl);
>>> +                     if (rfind)
>>> +                             *rfind = '\0';
>>> +                     else {
>>> +                             rfind = strrchr(remoteurl, ':');
>>> +                             if (rfind) {
>>> +                                     *rfind = '\0';
>>> +                                     colonsep = 1;
>>> +                             } else {
>>> +                                     if (is_relative || !strcmp(".", remoteurl))
>>> +                                             die(_("cannot strip one component off url '%s'"), remoteurl);
>>> +                                     else
>>> +                                             remoteurl = xstrdup(".");
>>> +                             }
>>> +                     }
>>
>> It is somewhat hard to see how this avoids stripping one (or both)
>> slashes just after "http:" in remoteurl="http://site/path/", leaving
>> just "http:/" (or "http:").
>
> it would leave just 'http:/' if url were to be ../../some/where/else,
> such that the constructed url below would be http://some/where/else.

Is that a good outcome, though?  Isn't it something we would want to
catch as an error?

  parent reply	other threads:[~2016-01-15 17:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-13 18:15 [PATCH] submodule: Port resolve_relative_url from shell to C Stefan Beller
2016-01-13 22:03 ` Junio C Hamano
2016-01-13 22:47   ` Stefan Beller
2016-01-14 20:50     ` Jens Lehmann
2016-01-14 23:43       ` Stefan Beller
2016-01-15 17:37     ` Junio C Hamano [this message]
2016-01-15 22:58       ` Stefan Beller
2016-01-15 23:03         ` Junio C Hamano
2016-01-14 20:57   ` Johannes Sixt
2016-01-14 22:49     ` Stefan Beller
2016-01-13 22:03 ` Eric Sunshine
2016-01-13 23:37   ` Stefan Beller
  -- strict thread matches above, loose matches on Subject: below --
2015-12-10  1:07 Stefan Beller
2015-12-10  6:48 ` Johannes Sixt
2015-12-16 22:36   ` Stefan Beller

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=xmqqwpraiw15.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=j6t@kdbg$(echo .)org \
    --cc=jens.lehmann@web$(echo .)de \
    --cc=peff@peff$(echo .)net \
    --cc=sbeller@google$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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