git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Steven Lawler <steven.lawler777@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [Bug] Query string not being phrased correctly when question marks present in config URL.
Date: Tue, 23 Sep 2014 05:06:27 -0400	[thread overview]
Message-ID: <20140923090627.GB7644@peff.net> (raw)
In-Reply-To: <CAOf__z5DTzchZpnz-DzoOEHnt8RdypV7=RPP1=AzinsskQEg8w@mail.gmail.com>

On Tue, Sep 23, 2014 at 04:20:55AM +1000, Steven Lawler wrote:

> Cause:
> [remote "repo"]
>   url = http://example.com/git/example.com?foo=bar
> There is a question mark in the URL of the repo URL.

Is the question mark there because it is separating query parameters
from the path, or is "?foo=bar" part of the literal path? If the latter,
it needs to be percent-escaped.

> Effect (Taken from Apache logs):
> [22/Sep/2014:14:12:07 -0400] "GET
> /git/example.com?foo=bar/info/refs&service=git-receive-pack HTTP/1.1"
> 403 207 "-" "git/1.9.4.msysgit.1"
> 
> Git attempts to correct the issue by making the query string continue
> using ampersands where it would have started the original query
> string.

It has to, because:

  http://example.com/git/example.com?foo=bar?service=git-receive-pack

would not mark the "service" parameter as a separate parameter of the
query-string.  However, from your expected output below, I do not think
that part is the thing you are complaining about:

> Expected outcome:
> The git client should move the ?foo=bar onto the beginning (or end) of
> the query string that it is creating. For example:
> [22/Sep/2014:14:12:07 -0400] "GET
> /git/example.com/info/refs?foo=bar&service=git-receive-pack HTTP/1.1"
> 403 207 "-" "git/1.9.4.msysgit.1"

The difference here is not the ampersand but the placement of
"info/refs".  Let's forget about the "service" parameter for a moment.
Git needs to access the "info/refs" directory of the repo specified by
the URL it is passed. Given:

  http://host/path?key=value

which part of the URL specifies the path to the repository (and that we
could munge to access info/refs)? I do not think there is a well-defined
answer. If "path" is the path to the repo and "key=value" is an
unrelated parameter, you would want:

  http://host/path/info/refs?key=value

which matches your example. But if the key is specifying the repository
path in its value, you would want to append it directly there. For
example,

  http://host/git?path=my-repo.git

should become:

  http://host/git?path=my-repo.git/info/refs

So I think you would need a config option or other mechanism to specify
which form your URL requires.

-Peff

      reply	other threads:[~2014-09-23  9:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-22 18:20 [Bug] Query string not being phrased correctly when question marks present in config URL Steven Lawler
2014-09-23  9:06 ` Jeff King [this message]

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=20140923090627.GB7644@peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=steven.lawler777@gmail.com \
    /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).