From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Sebastian Gniazdowski <sgniazdowski@gmail.com>, git@vger.kernel.org
Subject: Re: [BUG] Password cannot contain hash
Date: Mon, 9 Sep 2019 18:15:02 -0400 [thread overview]
Message-ID: <20190909221501.GA31319@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqq5zm1i0xv.fsf@gitster-ct.c.googlers.com>
On Mon, Sep 09, 2019 at 03:01:32PM -0700, Junio C Hamano wrote:
> Sebastian Gniazdowski <sgniazdowski@gmail.com> writes:
>
> > Hello,
> > if the password contains a hash, then it's impossible to clone a
> > repository, either with https or ssh protocols. I've had to use a
> > `gitg' GUI to clone such a repo.
>
> Hmph, do you mean that
>
> git clone https://user:password@hosting.site/repository/
> git clone ssh://user:password@hosting.site/repository/
>
> if the "password" has '#' in it? Do passwords with colon, slash or
> at-sign have the same issue? Would it help to URI escape the
> problematic characters?
>
> It is a separate issue to use passwords embedded in the URLs, but
> still, escaping ought to work.
It does need escaped in a URL, or we complain. I wondered if we might be
screwing it up elsewhere in the code, too, but t5550 seems to pass with
the modification below.
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index 0d985758c6..a1bc0019c9 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -154,7 +154,7 @@ prepare_httpd() {
HTTPD_DEST=127.0.0.1:$LIB_HTTPD_PORT
HTTPD_URL=$HTTPD_PROTO://$HTTPD_DEST
HTTPD_URL_USER=$HTTPD_PROTO://user%40host@$HTTPD_DEST
- HTTPD_URL_USER_PASS=$HTTPD_PROTO://user%40host:pass%40host@$HTTPD_DEST
+ HTTPD_URL_USER_PASS=$HTTPD_PROTO://user%40host:a%23hash@$HTTPD_DEST
if test -n "$LIB_HTTPD_DAV" || test -n "$LIB_HTTPD_SVN"
then
diff --git a/t/lib-httpd/passwd b/t/lib-httpd/passwd
index 99a34d6487..636ba5b9eb 100644
--- a/t/lib-httpd/passwd
+++ b/t/lib-httpd/passwd
@@ -1 +1 @@
-user@host:xb4E8pqD81KQs
+user@host:xgK/KkMxjf9xU
diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh
index b811d89cfd..d1b64068e6 100755
--- a/t/t5550-http-fetch-dumb.sh
+++ b/t/t5550-http-fetch-dumb.sh
@@ -65,13 +65,13 @@ test_expect_success 'http auth can use user/pass in URL' '
'
test_expect_success 'http auth can use just user in URL' '
- set_askpass wrong pass@host &&
+ set_askpass wrong "a#hash" &&
git clone "$HTTPD_URL_USER/auth/dumb/repo.git" clone-auth-pass &&
expect_askpass pass user@host
'
test_expect_success 'http auth can request both user and pass' '
- set_askpass user@host pass@host &&
+ set_askpass user@host "a#hash" &&
git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-both &&
expect_askpass both user@host
'
@@ -80,7 +80,7 @@ test_expect_success 'http auth respects credential helper config' '
test_config_global credential.helper "!f() {
cat >/dev/null
echo username=user@host
- echo password=pass@host
+ echo password="a#hash"
}; f" &&
set_askpass wrong &&
git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-helper &&
@@ -89,21 +89,21 @@ test_expect_success 'http auth respects credential helper config' '
test_expect_success 'http auth can get username from config' '
test_config_global "credential.$HTTPD_URL.username" user@host &&
- set_askpass wrong pass@host &&
+ set_askpass wrong "a#hash" &&
git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-user &&
expect_askpass pass user@host
'
test_expect_success 'configured username does not override URL' '
test_config_global "credential.$HTTPD_URL.username" wrong &&
- set_askpass wrong pass@host &&
+ set_askpass wrong "a#hash" &&
git clone "$HTTPD_URL_USER/auth/dumb/repo.git" clone-auth-user2 &&
expect_askpass pass user@host
'
test_expect_success 'set up repo with http submodules' '
git init super &&
- set_askpass user@host pass@host &&
+ set_askpass user@host "a#hash" &&
(
cd super &&
git submodule add "$HTTPD_URL/auth/dumb/repo.git" sub &&
@@ -112,21 +112,21 @@ test_expect_success 'set up repo with http submodules' '
'
test_expect_success 'cmdline credential config passes to submodule via clone' '
- set_askpass wrong pass@host &&
+ set_askpass wrong "a#hash" &&
test_must_fail git clone --recursive super super-clone &&
rm -rf super-clone &&
- set_askpass wrong pass@host &&
+ set_askpass wrong "a#hash" &&
git -c "credential.$HTTPD_URL.username=user@host" \
clone --recursive super super-clone &&
expect_askpass pass user@host
'
test_expect_success 'cmdline credential config passes submodule via fetch' '
- set_askpass wrong pass@host &&
+ set_askpass wrong "a#hash" &&
test_must_fail git -C super-clone fetch --recurse-submodules &&
- set_askpass wrong pass@host &&
+ set_askpass wrong "a#hash" &&
git -C super-clone \
-c "credential.$HTTPD_URL.username=user@host" \
fetch --recurse-submodules &&
@@ -140,10 +140,10 @@ test_expect_success 'cmdline credential config passes submodule update' '
sha1=$(git rev-parse HEAD) &&
git -C super-clone update-index --cacheinfo 160000,$sha1,sub &&
- set_askpass wrong pass@host &&
+ set_askpass wrong "a#hash" &&
test_must_fail git -C super-clone submodule update &&
- set_askpass wrong pass@host &&
+ set_askpass wrong "a#hash" &&
git -C super-clone \
-c "credential.$HTTPD_URL.username=user@host" \
submodule update &&
prev parent reply other threads:[~2019-09-09 22:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-09 21:18 [BUG] Password cannot contain hash Sebastian Gniazdowski
2019-09-09 22:01 ` Junio C Hamano
2019-09-09 22:15 ` 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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190909221501.GA31319@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sgniazdowski@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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).