git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] Do not decode url protocol.
@ 2010-06-22 11:58 Pascal Obry
  2010-06-22 16:08 ` Matthieu Moy
  0 siblings, 1 reply; 5+ messages in thread
From: Pascal Obry @ 2010-06-22 11:58 UTC (permalink / raw)
  To: Git Mailing List

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;

-- 
1.7.1.524.g6df2f

Ok, given Matthieu comments here is another version of the patch which
should apply cleanly
and won't clobber log message with my comments!

Note that it is safe to do this in url_decode_internal as we know that
here we have an url
with a protocol specified.

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] Do not decode url protocol.
  2010-06-22 11:58 [PATCH v3] Do not decode url protocol Pascal Obry
@ 2010-06-22 16:08 ` Matthieu Moy
  2010-06-22 16:47   ` Pascal Obry
  0 siblings, 1 reply; 5+ messages in thread
From: Matthieu Moy @ 2010-06-22 16:08 UTC (permalink / raw)
  To: Pascal Obry; +Cc: Git Mailing List

Pascal Obry <pascal@obry.net> writes:

> -- 
> 1.7.1.524.g6df2f
>
> Ok, given Matthieu comments here is another version of the patch which
> should apply cleanly
> and won't clobber log message with my comments!

Thanks for making the life of our maintainer easier :-).

Unfortunately, it's still not the right place for comments ;-). That's
OK with Git AFAICT, but readers expect them between the --- (tripple)
and the diffstat.

Unless I missed something, this version doesn't address my earlier
comment:

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> Pascal Obry <pascal@obry.net> writes:
>
>> @@ -70,9 +70,18 @@ static int url_decode_char(const char *q)
>>  static char *url_decode_internal(const char **query, const char *stop_at)
>>  {
>
> This function is called from multiple places :

[...]

> I don't think you want to avoid escaping until the first slash in
> url_decode_parameter_name and url_decode_parameter_value. I think you
> want to patch url_decode, not url_decode_internal.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] Do not decode url protocol.
  2010-06-22 16:08 ` Matthieu Moy
@ 2010-06-22 16:47   ` Pascal Obry
  2010-06-22 17:08     ` Matthieu Moy
  0 siblings, 1 reply; 5+ messages in thread
From: Pascal Obry @ 2010-06-22 16:47 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Git Mailing List

Matthieu,

> Unless I missed something, this version doesn't address my earlier
> comment:

Because I do not agree. The three procedures:

char *url_decode(const char *url)
char *url_decode_parameter_name(const char **query)
char *url_decode_parameter_value(const char **query)

are all passed a full url (with protocol). We do not want to decode the
protocol in all three cases. The difference is only that the later two
are stopping the decoding at a given point in the url.

So to me, until I'm proved to be wrong, I think that v3 of my path is
correct.

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] Do not decode url protocol.
  2010-06-22 16:47   ` Pascal Obry
@ 2010-06-22 17:08     ` Matthieu Moy
  2010-06-22 17:22       ` Pascal Obry
  0 siblings, 1 reply; 5+ messages in thread
From: Matthieu Moy @ 2010-06-22 17:08 UTC (permalink / raw)
  To: pascal; +Cc: Git Mailing List

Pascal Obry <pascal.obry@gmail.com> writes:

> Matthieu,
>
>> Unless I missed something, this version doesn't address my earlier
>> comment:
>
> Because I do not agree.

I'm fine with disagreeing, but then you should argue. This would allow
either Junio to be convinced, or me to argue back.

> The three procedures:
>
> char *url_decode(const char *url)
> char *url_decode_parameter_name(const char **query)
> char *url_decode_parameter_value(const char **query)
>
> are all passed a full url (with protocol).

The caller is this (http-backend.c):

static struct string_list *get_parameters(void)
{
[...]
		while (query && *query) {
			char *name = url_decode_parameter_name(&query);
			char *value = url_decode_parameter_value(&query);
			[...]
		}

which advances "query" as the URL is decoded, hence passing query as a
pointer to the argument being parsed, not to the full URL.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] Do not decode url protocol.
  2010-06-22 17:08     ` Matthieu Moy
@ 2010-06-22 17:22       ` Pascal Obry
  0 siblings, 0 replies; 5+ messages in thread
From: Pascal Obry @ 2010-06-22 17:22 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Git Mailing List

Matthieu,

> which advances "query" as the URL is decoded, hence passing query as a
> pointer to the argument being parsed, not to the full URL.

Ok, I've missed that and I'm wrong :) Will propose another patch.

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-06-22 17:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-22 11:58 [PATCH v3] Do not decode url protocol Pascal Obry
2010-06-22 16:08 ` Matthieu Moy
2010-06-22 16:47   ` Pascal Obry
2010-06-22 17:08     ` Matthieu Moy
2010-06-22 17:22       ` Pascal Obry

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).