]> git.ipfire.org Git - thirdparty/git.git/blobdiff - credential.c
upload-pack: pass upload_pack_data to send_acks()
[thirdparty/git.git] / credential.c
index 4e7197d97a96d29326227b7957863135a4b2e7b6..d8d226b97e34805735cc14bdc3e549d012b33f8d 100644 (file)
@@ -157,14 +157,14 @@ static void credential_format(struct credential *c, struct strbuf *out)
                return;
        strbuf_addf(out, "%s://", c->protocol);
        if (c->username && *c->username) {
-               strbuf_add_percentencode(out, c->username);
+               strbuf_add_percentencode(out, c->username, STRBUF_ENCODE_SLASH);
                strbuf_addch(out, '@');
        }
        if (c->host)
                strbuf_addstr(out, c->host);
        if (c->path) {
                strbuf_addch(out, '/');
-               strbuf_add_percentencode(out, c->path);
+               strbuf_add_percentencode(out, c->path, 0);
        }
 }
 
@@ -443,7 +443,14 @@ static int credential_from_url_1(struct credential *c, const char *url,
        cp = proto_end ? proto_end + 3 : url;
        at = strchr(cp, '@');
        colon = strchr(cp, ':');
-       slash = strchrnul(cp, '/');
+
+       /*
+        * A query or fragment marker before the slash ends the host portion.
+        * We'll just continue to call this "slash" for simplicity. Notably our
+        * "trim leading slashes" part won't skip over this part of the path,
+        * but that's what we'd want.
+        */
+       slash = cp + strcspn(cp, "/?#");
 
        if (!at || slash <= at) {
                /* Case (1) */