All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] t0300: workaround bug in FreeBSD < 10 sh
@ 2020-05-14 21:05 Carlo Marcelo Arenas Belón
  2020-05-14 22:03 ` Jeff King
  2020-05-14 22:55 ` brian m. carlson
  0 siblings, 2 replies; 7+ messages in thread
From: Carlo Marcelo Arenas Belón @ 2020-05-14 21:05 UTC (permalink / raw)
  To: git; +Cc: peff, Carlo Marcelo Arenas Belón

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@gmail.com>
---
 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


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

end of thread, other threads:[~2020-05-14 23:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-14 21:05 [PATCH] t0300: workaround bug in FreeBSD < 10 sh Carlo Marcelo Arenas Belón
2020-05-14 22:03 ` Jeff King
2020-05-14 22:44   ` Eric Sunshine
2020-05-14 23:30   ` Carlo Marcelo Arenas Belón
2020-05-14 22:55 ` brian m. carlson
2020-05-14 23:04   ` Junio C Hamano
2020-05-14 23:43     ` Carlo Marcelo Arenas Belón

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.