summaryrefslogtreecommitdiff
path: root/tests-clar
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2013-11-04 12:04:17 -0800
committerBen Straub <bs@github.com>2013-11-04 12:04:17 -0800
commit16bffd1c26d8d22a61b5d99fd4063c2f71751317 (patch)
treeda28c57a3d7bc54817a8331b6165c1bde759f930 /tests-clar
parentc227c173b84c8107a8933aeed947f16d82224377 (diff)
downloadlibgit2-16bffd1c26d8d22a61b5d99fd4063c2f71751317.tar.gz
Unescape url-encoded usernames and passwords
Diffstat (limited to 'tests-clar')
-rw-r--r--tests-clar/network/urlparse.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/tests-clar/network/urlparse.c b/tests-clar/network/urlparse.c
index 4babb0fa7..3ec3a51a3 100644
--- a/tests-clar/network/urlparse.c
+++ b/tests-clar/network/urlparse.c
@@ -33,7 +33,7 @@ void test_network_urlparse__trivial(void)
cl_assert_equal_p(pass, NULL);
}
-void test_network_urlparse__weird_url(void)
+void test_network_urlparse__encoded_password(void)
{
cl_git_pass(gitno_extract_url_parts(&host, &port, &path, &user, &pass,
"https://user:pass%2fis%40bad@hostname.com:1234/", "1"));
@@ -41,7 +41,7 @@ void test_network_urlparse__weird_url(void)
cl_assert_equal_s(port, "1234");
cl_assert_equal_s(path, "/");
cl_assert_equal_s(user, "user");
- cl_assert_equal_s(pass, "pass%2fis%40bad");
+ cl_assert_equal_s(pass, "pass/is@bad");
}
void test_network_urlparse__user(void)
@@ -127,6 +127,18 @@ void test_network_urlparse__connection_data_ssl(void)
cl_assert_equal_i(conndata.use_ssl, true);
}
+void test_network_urlparse__encoded_username_password(void)
+{
+ cl_git_pass(gitno_connection_data_from_url(&conndata,
+ "https://user%2fname:pass%40word@example.com/foo/bar/baz", "bar/baz"));
+ cl_assert_equal_s(conndata.host, "example.com");
+ cl_assert_equal_s(conndata.port, "443");
+ cl_assert_equal_s(conndata.path, "/foo/");
+ cl_assert_equal_s(conndata.user, "user/name");
+ cl_assert_equal_s(conndata.pass, "pass@word");
+ cl_assert_equal_i(conndata.use_ssl, true);
+}
+
void test_network_urlparse__connection_data_cross_host_redirect(void)
{
conndata.host = git__strdup("bar.com");