git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] Do not decode url protocol.
@ 2010-06-22 20:16 Pascal Obry
  2010-06-22 21:39 ` Matthieu Moy
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Pascal Obry @ 2010-06-22 20:16 UTC (permalink / raw)
  To: git list, Matthieu Moy


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.
---
 url.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

Ok, so this is the fourth version of this patch. Thanks again Matthieu
for the review. I think this time I got the place for the message right :)

Anyway, I think this time we properly skip the protocol decoding when
needed.

diff --git a/url.c b/url.c
index cd32b92..0eb7fb3 100644
--- a/url.c
+++ b/url.c
@@ -67,12 +67,23 @@ static int url_decode_char(const char *q)
        return val;
 }

-static char *url_decode_internal(const char **query, const char *stop_at)
+static char *url_decode_internal(const char **query, const char *stop_at,
+               int with_protocol)
 {
        const char *q = *query;
+       const char *first_slash;
        struct strbuf out;

        strbuf_init(&out, 16);
+
+       /* Skip protocol if present. */
+       if (with_protocol) {
+         first_slash = strchr(*query, '/');
+
+         while (q < first_slash)
+               strbuf_addch(&out, *q++);
+       }
+
        do {
                unsigned char c = *q;

@@ -104,15 +115,15 @@ static char *url_decode_internal(const char
**query, const char *stop_at)

 char *url_decode(const char *url)
 {
-       return url_decode_internal(&url, NULL);
+       return url_decode_internal(&url, NULL, 1);
 }

 char *url_decode_parameter_name(const char **query)
 {
-       return url_decode_internal(query, "&=");
+       return url_decode_internal(query, "&=", 0);
 }

 char *url_decode_parameter_value(const char **query)
 {
-       return url_decode_internal(query, "&");
+       return url_decode_internal(query, "&", 0);
 }
-- 
1.7.1.426.gb436.dirty

-- 

--|------------------------------------------------------
--| 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 related	[flat|nested] 5+ messages in thread

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2010-06-23 17:27 ` Junio C Hamano
2010-06-23 17:38   ` Jeff King

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