crypt32: Fix a string test.

This commit is contained in:
Christian Inci 2011-04-09 21:34:47 +02:00 committed by Alexandre Julliard
parent 7d5099e4fc
commit a0207c88a7
2 changed files with 33 additions and 2 deletions

View File

@ -1074,7 +1074,8 @@ BOOL WINAPI CertStrToNameW(DWORD dwCertEncodingType, LPCWSTR pszX500,
static const WCHAR commaSep[] = { ',',0 }; static const WCHAR commaSep[] = { ',',0 };
static const WCHAR semiSep[] = { ';',0 }; static const WCHAR semiSep[] = { ';',0 };
static const WCHAR crlfSep[] = { '\r','\n',0 }; static const WCHAR crlfSep[] = { '\r','\n',0 };
static const WCHAR allSeps[] = { ',',';','\r','\n',0 }; static const WCHAR allSepsWithoutPlus[] = { ',',';','\r','\n',0 };
static const WCHAR allSeps[] = { '+',',',';','\r','\n',0 };
LPCWSTR sep; LPCWSTR sep;
str++; str++;
@ -1084,6 +1085,8 @@ BOOL WINAPI CertStrToNameW(DWORD dwCertEncodingType, LPCWSTR pszX500,
sep = semiSep; sep = semiSep;
else if (dwStrType & CERT_NAME_STR_CRLF_FLAG) else if (dwStrType & CERT_NAME_STR_CRLF_FLAG)
sep = crlfSep; sep = crlfSep;
else if (dwStrType & CERT_NAME_STR_NO_PLUS_FLAG)
sep = allSepsWithoutPlus;
else else
sep = allSeps; sep = allSeps;
ret = CRYPT_GetNextValueW(str, dwStrType, sep, &token, ret = CRYPT_GetNextValueW(str, dwStrType, sep, &token,

View File

@ -800,8 +800,36 @@ static void test_CertStrToNameA(void)
"Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError()); "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1+2", 0, NULL, buf, ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1+2", 0, NULL, buf,
&size, NULL); &size, NULL);
todo_wine ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
"Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError()); "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1+2", CERT_NAME_STR_NO_PLUS_FLAG, NULL, buf,
&size, NULL);
ok(ret && GetLastError() == ERROR_SUCCESS,
"Expected ERROR_SUCCESS, got %08x\n", GetLastError());
ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1,2", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf,
&size, NULL);
ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
"Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=\"1,2;3,4\"", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf,
&size, NULL);
ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
"Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=abc", 0, NULL, buf,
&size, NULL);
ok(ret && GetLastError() == ERROR_SUCCESS,
"Expected ERROR_SUCCESS, got %08x\n", GetLastError());
ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=abc", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf,
&size, NULL);
ok(ret && GetLastError() == ERROR_SUCCESS,
"Expected ERROR_SUCCESS, got %08x\n", GetLastError());
ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=\"abc\"", 0, NULL, buf,
&size, NULL);
ok(ret && GetLastError() == ERROR_SUCCESS,
"Expected ERROR_SUCCESS, got %08x\n", GetLastError());
ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=\"abc\"", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf,
&size, NULL);
todo_wine ok(!ret && GetLastError() == ERROR_MORE_DATA,
"Expected ERROR_MORE_DATA, got %08x\n", GetLastError());
for (i = 0; i < sizeof(namesA) / sizeof(namesA[0]); i++) for (i = 0; i < sizeof(namesA) / sizeof(namesA[0]); i++)
{ {
size = sizeof(buf); size = sizeof(buf);