зеркало из https://github.com/microsoft/git.git
Merge branch 'js/wincred-empty-cred' into maint
MinGW updates. * js/wincred-empty-cred: wincred: handle empty username/password correctly t0302: check helper can handle empty credentials
This commit is contained in:
Коммит
558d8568df
|
@ -94,6 +94,12 @@ static WCHAR *wusername, *password, *protocol, *host, *path, target[1024];
|
||||||
static void write_item(const char *what, LPCWSTR wbuf, int wlen)
|
static void write_item(const char *what, LPCWSTR wbuf, int wlen)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
|
if (!wbuf || !wlen) {
|
||||||
|
printf("%s=\n", what);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int len = WideCharToMultiByte(CP_UTF8, 0, wbuf, wlen, NULL, 0, NULL,
|
int len = WideCharToMultiByte(CP_UTF8, 0, wbuf, wlen, NULL, 0, NULL,
|
||||||
FALSE);
|
FALSE);
|
||||||
buf = xmalloc(len);
|
buf = xmalloc(len);
|
||||||
|
@ -160,7 +166,7 @@ static int match_part_last(LPCWSTR *ptarget, LPCWSTR want, LPCWSTR delim)
|
||||||
static int match_cred(const CREDENTIALW *cred)
|
static int match_cred(const CREDENTIALW *cred)
|
||||||
{
|
{
|
||||||
LPCWSTR target = cred->TargetName;
|
LPCWSTR target = cred->TargetName;
|
||||||
if (wusername && wcscmp(wusername, cred->UserName))
|
if (wusername && wcscmp(wusername, cred->UserName ? cred->UserName : L""))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return match_part(&target, L"git", L":") &&
|
return match_part(&target, L"git", L":") &&
|
||||||
|
@ -183,7 +189,7 @@ static void get_credential(void)
|
||||||
for (i = 0; i < num_creds; ++i)
|
for (i = 0; i < num_creds; ++i)
|
||||||
if (match_cred(creds[i])) {
|
if (match_cred(creds[i])) {
|
||||||
write_item("username", creds[i]->UserName,
|
write_item("username", creds[i]->UserName,
|
||||||
wcslen(creds[i]->UserName));
|
creds[i]->UserName ? wcslen(creds[i]->UserName) : 0);
|
||||||
write_item("password",
|
write_item("password",
|
||||||
(LPCWSTR)creds[i]->CredentialBlob,
|
(LPCWSTR)creds[i]->CredentialBlob,
|
||||||
creds[i]->CredentialBlobSize / sizeof(WCHAR));
|
creds[i]->CredentialBlobSize / sizeof(WCHAR));
|
||||||
|
|
|
@ -44,6 +44,7 @@ helper_test_clean() {
|
||||||
reject $1 https example.com user2
|
reject $1 https example.com user2
|
||||||
reject $1 http path.tld user
|
reject $1 http path.tld user
|
||||||
reject $1 https timeout.tld user
|
reject $1 https timeout.tld user
|
||||||
|
reject $1 https sso.tld
|
||||||
}
|
}
|
||||||
|
|
||||||
reject() {
|
reject() {
|
||||||
|
@ -250,6 +251,24 @@ helper_test() {
|
||||||
password=pass2
|
password=pass2
|
||||||
EOF
|
EOF
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success "helper ($HELPER) can store empty username" '
|
||||||
|
check approve $HELPER <<-\EOF &&
|
||||||
|
protocol=https
|
||||||
|
host=sso.tld
|
||||||
|
username=
|
||||||
|
password=
|
||||||
|
EOF
|
||||||
|
check fill $HELPER <<-\EOF
|
||||||
|
protocol=https
|
||||||
|
host=sso.tld
|
||||||
|
--
|
||||||
|
protocol=https
|
||||||
|
host=sso.tld
|
||||||
|
username=
|
||||||
|
password=
|
||||||
|
EOF
|
||||||
|
'
|
||||||
}
|
}
|
||||||
|
|
||||||
helper_test_timeout() {
|
helper_test_timeout() {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче