4c5971e18a (credential: treat "?" and "#" in URLs as end of host, 2020-04-14) introduces check_host_and_path to t0300 and some tests that use it, but fail in at least FreeBSD 9.3. The variables in the here-doc fail to be expanded until they are used as part of the eval in check(), resulting in (ex: url=fill) instead of what was expected. Transfer the 3 parameters to local variables which will be used instead and that will be in scope without conflicting names. While at it, make sure all of the parameters which potentially sensitive characters (ex: ?#), are quote protected. Signed-off-by: Carlo Marcelo Arenas Belón <carenas@xxxxxxxxx> --- t/t0300-credentials.sh | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh index bc2d74098f..e0b7c001f1 100755 --- a/t/t0300-credentials.sh +++ b/t/t0300-credentials.sh @@ -622,37 +622,43 @@ test_expect_success 'credential system refuses to work with missing protocol' ' # usage: check_host_and_path <url> <expected-host> <expected-path> check_host_and_path () { + local url=$1 + local host=$2 + local path=$3 + # we always parse the path component, but we need this to make sure it # is passed to the helper test_config credential.useHTTPPath true && - check fill "verbatim user pass" <<-EOF - url=$1 + check fill 'verbatim user pass' <<-EOF + url=$url -- protocol=https - host=$2 - path=$3 + host=$host + path=$path username=user password=pass -- verbatim: get verbatim: protocol=https - verbatim: host=$2 - verbatim: path=$3 + verbatim: host=$host + verbatim: path=$path EOF } -test_expect_success 'url parser handles bare query marker' ' - check_host_and_path https://example.com?foo.git example.com ?foo.git -' +test_expect_success 'url parser handles bare query marker' " + check_host_and_path 'https://example.com?foo.git' \ + example.com '?foo.git' +" -test_expect_success 'url parser handles bare fragment marker' ' - check_host_and_path https://example.com#foo.git example.com "#foo.git" -' +test_expect_success 'url parser handles bare fragment marker' " + check_host_and_path 'https://example.com#foo.git' \ + example.com '#foo.git' +" -test_expect_success 'url parser not confused by encoded markers' ' - check_host_and_path https://example.com%23%3f%2f/foo.git \ - "example.com#?/" foo.git -' +test_expect_success 'url parser not confused by encoded markers' " + check_host_and_path 'https://example.com%23%3f%2f/foo.git' \ + 'example.com#?/' foo.git +" test_expect_success 'credential config with partial URLs' ' echo "echo password=yep" | write_script git-credential-yep && -- 2.26.2.812.g046d49d455