Skip to content

Commit 0bd71aa

Browse files
committed
WIP additinoal tests
1 parent 146642e commit 0bd71aa

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

src/libutil-tests/url.cc

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,57 @@ INSTANTIATE_TEST_SUITE_P(
241241
.authority = ParsedURL::Authority{},
242242
.path = {"", "a", "b", "%20"},
243243
},
244+
},
245+
// Git SCP edge cases: brackets not at start, colon comes before bracket handling kicks in.
246+
// `git clone 'user[2001:db8:1::2]:/home/@file'` -> ssh: Could not resolve hostname user[2001
247+
// Git splits on first `:`, treating `user[2001` as hostname.
248+
FixGitURLParam{
249+
.input = "user[2001:db8:1::2]:/home/@file",
250+
.expected = "ssh://user%5B2001/%5Bdb8:1::2%5D:/home/@file",
251+
.parsed =
252+
ParsedURL{
253+
.scheme = "ssh",
254+
.authority =
255+
ParsedURL::Authority{
256+
.hostType = ParsedURL::Authority::HostType::Name,
257+
.host = "user[2001",
258+
},
259+
.path = {"", "[db8:1::2]:", "home", "@file"},
260+
},
261+
},
262+
// `git clone 'user:[2001:db8:1::2]:/home/@file'` -> ssh: Could not resolve hostname user
263+
// Git treats `user` as hostname, rest is path.
264+
FixGitURLParam{
265+
.input = "user:[2001:db8:1::2]:/home/@file",
266+
.expected = "ssh://user/%5B2001:db8:1::2%5D:/home/@file",
267+
.parsed =
268+
ParsedURL{
269+
.scheme = "ssh",
270+
.authority =
271+
ParsedURL::Authority{
272+
.hostType = ParsedURL::Authority::HostType::Name,
273+
.host = "user",
274+
},
275+
.path = {"", "[2001:db8:1::2]:", "home", "@file"},
276+
},
277+
},
278+
// `git clone 'user:@[2001:db8:1::2]:/home/file'` -> tries to connect to IPv6
279+
// Git treats `user:` as username (with empty password), IPv6 as host.
280+
FixGitURLParam{
281+
.input = "user:@[2001:db8:1::2]:/home/file",
282+
.expected = "ssh://user:@[2001:db8:1::2]/home/file",
283+
.parsed =
284+
ParsedURL{
285+
.scheme = "ssh",
286+
.authority =
287+
ParsedURL::Authority{
288+
.hostType = ParsedURL::Authority::HostType::IPv6,
289+
.host = "2001:db8:1::2",
290+
.user = "user",
291+
.password = "",
292+
},
293+
.path = {"", "home", "file"},
294+
},
244295
}));
245296

246297
TEST_P(FixGitURLTestSuite, parsesVariedGitUrls)

0 commit comments

Comments
 (0)