static void InternetCrackUrl_test(void) { URL_COMPONENTSA urlSrc, urlComponents; char protocol[32], hostName[1024], userName[1024]; char password[1024], extra[1024], path[1024]; BOOL ret, firstret; DWORD GLE, firstGLE; ZeroMemory(&urlSrc, sizeof(urlSrc)); urlSrc.dwStructSize = sizeof(urlSrc); urlSrc.lpszScheme = protocol; urlSrc.lpszHostName = hostName; urlSrc.lpszUserName = userName; urlSrc.lpszPassword = password; urlSrc.lpszUrlPath = path; urlSrc.lpszExtraInfo = extra; /* Tests for lpsz* members pointing to real strings while * some corresponding length members are set to zero. * As of IE7 (wininet 7.0*?) all members are checked. So we * run the first test and expect the outcome to be the same * for the first four (scheme, hostname, username and password). * The last two (path and extrainfo) are the same for all versions * of the wininet.dll. */ copy_compsA(&urlSrc, &urlComponents, 0, 1024, 1024, 1024, 2048, 1024); SetLastError(0xdeadbeef); firstret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents); firstGLE = GetLastError(); copy_compsA(&urlSrc, &urlComponents, 32, 0, 1024, 1024, 2048, 1024); SetLastError(0xdeadbeef); ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents); GLE = GetLastError(); ok(ret==firstret && (GLE==firstGLE), "InternetCrackUrl returned %d with GLE=%d (expected to return %d)\n", ret, GetLastError(), firstret); copy_compsA(&urlSrc, &urlComponents, 32, 1024, 0, 1024, 2048, 1024); SetLastError(0xdeadbeef); ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents); GLE = GetLastError(); ok(ret==firstret && (GLE==firstGLE), "InternetCrackUrl returned %d with GLE=%d (expected to return %d)\n", ret, GetLastError(), firstret); copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 0, 2048, 1024); SetLastError(0xdeadbeef); ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents); GLE = GetLastError(); ok(ret==firstret && (GLE==firstGLE), "InternetCrackUrl returned %d with GLE=%d (expected to return %d)\n", ret, GetLastError(), firstret); copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 0, 1024); SetLastError(0xdeadbeef); ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents); GLE = GetLastError(); todo_wine ok(ret==0 && (GLE==ERROR_INVALID_HANDLE || GLE==ERROR_INSUFFICIENT_BUFFER), "InternetCrackUrl returned %d with GLE=%d (expected to return 0 and ERROR_INVALID_HANDLE or ERROR_INSUFFICIENT_BUFFER)\n", ret, GLE); copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 0); SetLastError(0xdeadbeef); ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents); GLE = GetLastError(); todo_wine ok(ret==0 && (GLE==ERROR_INVALID_HANDLE || GLE==ERROR_INSUFFICIENT_BUFFER), "InternetCrackUrl returned %d with GLE=%d (expected to return 0 and ERROR_INVALID_HANDLE or ERROR_INSUFFICIENT_BUFFER)\n", ret, GLE); copy_compsA(&urlSrc, &urlComponents, 0, 0, 0, 0, 0, 0); ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents); GLE = GetLastError(); todo_wine ok(ret==0 && GLE==ERROR_INVALID_PARAMETER, "InternetCrackUrl returned %d with GLE=%d (expected to return 0 and ERROR_INVALID_PARAMETER)\n", ret, GLE); copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024); ret = InternetCrackUrl("about://host/blank", 0,0,&urlComponents); ok(ret, "InternetCrackUrl failed with %d\n", GetLastError()); ok(!strcmp(urlComponents.lpszScheme, "about"), "lpszScheme was \"%s\" instead of \"about\"\n", urlComponents.lpszScheme); ok(!strcmp(urlComponents.lpszHostName, "host"), "lpszHostName was \"%s\" instead of \"host\"\n", urlComponents.lpszHostName); ok(!strcmp(urlComponents.lpszUrlPath, "/blank"), "lpszUrlPath was \"%s\" instead of \"/blank\"\n", urlComponents.lpszUrlPath); /* try a NULL lpszUrl */ SetLastError(0xdeadbeef); copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024); ret = InternetCrackUrl(NULL, 0, 0, &urlComponents); GLE = GetLastError(); ok(ret == FALSE, "Expected InternetCrackUrl to fail\n"); ok(GLE == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GLE); /* try an empty lpszUrl, GetLastError returns 12006, whatever that means * we just need to fail and not return success */ SetLastError(0xdeadbeef); copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024); ret = InternetCrackUrl("", 0, 0, &urlComponents); GLE = GetLastError(); ok(ret == FALSE, "Expected InternetCrackUrl to fail\n"); ok(GLE != 0xdeadbeef && GLE != ERROR_SUCCESS, "Expected GLE to represent a failure\n"); /* Invalid Call: must set size of components structure (Windows only * enforces this on the InternetCrackUrlA version of the call) */ copy_compsA(&urlSrc, &urlComponents, 0, 1024, 1024, 1024, 2048, 1024); SetLastError(0xdeadbeef); urlComponents.dwStructSize = 0; ret = InternetCrackUrlA(TEST_URL, 0, 0, &urlComponents); ok(ret == FALSE, "Expected InternetCrackUrl to fail\n"); ok(GLE != 0xdeadbeef && GLE != ERROR_SUCCESS, "Expected GLE to represent a failure\n"); /* Invalid Call: size of dwStructSize must be one of the "standard" sizes * of the URL_COMPONENTS structure (Windows only enforces this on the * InternetCrackUrlA version of the call) */ copy_compsA(&urlSrc, &urlComponents, 0, 1024, 1024, 1024, 2048, 1024); SetLastError(0xdeadbeef); urlComponents.dwStructSize = sizeof(urlComponents) + 1; ret = InternetCrackUrlA(TEST_URL, 0, 0, &urlComponents); ok(ret == FALSE, "Expected InternetCrackUrl to fail\n"); ok(GLE != 0xdeadbeef && GLE != ERROR_SUCCESS, "Expected GLE to represent a failure\n"); }
static void InternetCrackUrl_test(void) { URL_COMPONENTSA urlSrc, urlComponents; char protocol[32], hostName[1024], userName[1024]; char password[1024], extra[1024], path[1024]; BOOL ret, firstret; DWORD GLE, firstGLE; ZeroMemory(&urlSrc, sizeof(urlSrc)); urlSrc.dwStructSize = sizeof(urlSrc); urlSrc.lpszScheme = protocol; urlSrc.lpszHostName = hostName; urlSrc.lpszUserName = userName; urlSrc.lpszPassword = password; urlSrc.lpszUrlPath = path; urlSrc.lpszExtraInfo = extra; copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024); ret = InternetCrackUrl(TEST_URL, 0,0,&urlComponents); ok( ret, "InternetCrackUrl failed, error %d\n",GetLastError()); ok((strcmp(TEST_URL_PATH,path) == 0),"path cracked wrong\n"); /* Bug 1805: Confirm the returned lengths are correct: */ /* 1. When extra info split out explicitly */ zero_compsA(&urlComponents, 0, 1, 0, 0, 1, 1); ok(InternetCrackUrlA(TEST_URL2, 0, 0, &urlComponents),"InternetCrackUrl failed, error %d\n", GetLastError()); ok(urlComponents.dwUrlPathLength == strlen(TEST_URL2_PATH),".dwUrlPathLength should be %d, but is %d\n", (DWORD)strlen(TEST_URL2_PATH), urlComponents.dwUrlPathLength); ok(!strncmp(urlComponents.lpszUrlPath,TEST_URL2_PATH,strlen(TEST_URL2_PATH)),"lpszUrlPath should be %s but is %s\n", TEST_URL2_PATH, urlComponents.lpszUrlPath); ok(urlComponents.dwHostNameLength == strlen(TEST_URL2_SERVER),".dwHostNameLength should be %d, but is %d\n", (DWORD)strlen(TEST_URL2_SERVER), urlComponents.dwHostNameLength); ok(!strncmp(urlComponents.lpszHostName,TEST_URL2_SERVER,strlen(TEST_URL2_SERVER)),"lpszHostName should be %s but is %s\n", TEST_URL2_SERVER, urlComponents.lpszHostName); ok(urlComponents.dwExtraInfoLength == strlen(TEST_URL2_EXTRA),".dwExtraInfoLength should be %d, but is %d\n", (DWORD)strlen(TEST_URL2_EXTRA), urlComponents.dwExtraInfoLength); ok(!strncmp(urlComponents.lpszExtraInfo,TEST_URL2_EXTRA,strlen(TEST_URL2_EXTRA)),"lpszExtraInfo should be %s but is %s\n", TEST_URL2_EXTRA, urlComponents.lpszHostName); /* 2. When extra info is not split out explicitly and is in url path */ zero_compsA(&urlComponents, 0, 1, 0, 0, 1, 0); ok(InternetCrackUrlA(TEST_URL2, 0, 0, &urlComponents),"InternetCrackUrl failed with GLE %d\n",GetLastError()); ok(urlComponents.dwUrlPathLength == strlen(TEST_URL2_PATHEXTRA),".dwUrlPathLength should be %d, but is %d\n", (DWORD)strlen(TEST_URL2_PATHEXTRA), urlComponents.dwUrlPathLength); ok(!strncmp(urlComponents.lpszUrlPath,TEST_URL2_PATHEXTRA,strlen(TEST_URL2_PATHEXTRA)),"lpszUrlPath should be %s but is %s\n", TEST_URL2_PATHEXTRA, urlComponents.lpszUrlPath); ok(urlComponents.dwHostNameLength == strlen(TEST_URL2_SERVER),".dwHostNameLength should be %d, but is %d\n", (DWORD)strlen(TEST_URL2_SERVER), urlComponents.dwHostNameLength); ok(!strncmp(urlComponents.lpszHostName,TEST_URL2_SERVER,strlen(TEST_URL2_SERVER)),"lpszHostName should be %s but is %s\n", TEST_URL2_SERVER, urlComponents.lpszHostName); ok(urlComponents.nPort == INTERNET_DEFAULT_HTTP_PORT,"urlComponents->nPort should have been 80 instead of %d\n", urlComponents.nPort); ok(urlComponents.nScheme == INTERNET_SCHEME_HTTP,"urlComponents->nScheme should have been INTERNET_SCHEME_HTTP instead of %d\n", urlComponents.nScheme); zero_compsA(&urlComponents, 1, 1, 1, 1, 1, 1); ok(InternetCrackUrlA(TEST_URL, strlen(TEST_URL), 0, &urlComponents),"InternetCrackUrl failed with GLE %d\n",GetLastError()); ok(urlComponents.dwUrlPathLength == strlen(TEST_URL_PATH),".dwUrlPathLength should be %d, but is %d\n", lstrlenA(TEST_URL_PATH), urlComponents.dwUrlPathLength); ok(!strncmp(urlComponents.lpszUrlPath,TEST_URL_PATH,strlen(TEST_URL_PATH)),"lpszUrlPath should be %s but is %s\n", TEST_URL_PATH, urlComponents.lpszUrlPath); ok(urlComponents.dwHostNameLength == strlen(TEST_URL_HOST),".dwHostNameLength should be %d, but is %d\n", lstrlenA(TEST_URL_HOST), urlComponents.dwHostNameLength); ok(!strncmp(urlComponents.lpszHostName,TEST_URL_HOST,strlen(TEST_URL_HOST)),"lpszHostName should be %s but is %s\n", TEST_URL_HOST, urlComponents.lpszHostName); ok(urlComponents.nPort == INTERNET_DEFAULT_HTTP_PORT,"urlComponents->nPort should have been 80 instead of %d\n", urlComponents.nPort); ok(urlComponents.nScheme == INTERNET_SCHEME_HTTP,"urlComponents->nScheme should have been INTERNET_SCHEME_HTTP instead of %d\n", urlComponents.nScheme); ok(!urlComponents.lpszUserName, ".lpszUserName should have been set to NULL\n"); ok(!urlComponents.lpszPassword, ".lpszPassword should have been set to NULL\n"); ok(!urlComponents.lpszExtraInfo, ".lpszExtraInfo should have been set to NULL\n"); ok(!urlComponents.dwUserNameLength,".dwUserNameLength should be 0, but is %d\n", urlComponents.dwUserNameLength); ok(!urlComponents.dwPasswordLength,".dwPasswordLength should be 0, but is %d\n", urlComponents.dwPasswordLength); ok(!urlComponents.dwExtraInfoLength,".dwExtraInfoLength should be 0, but is %d\n", urlComponents.dwExtraInfoLength); /*3. Check for %20 */ copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024); ok(InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents),"InternetCrackUrl failed with GLE %d\n",GetLastError()); /* Tests for lpsz* members pointing to real strings while * some corresponding length members are set to zero. * As of IE7 (wininet 7.0*?) all members are checked. So we * run the first test and expect the outcome to be the same * for the first four (scheme, hostname, username and password). * The last two (path and extrainfo) are the same for all versions * of the wininet.dll. */ copy_compsA(&urlSrc, &urlComponents, 0, 1024, 1024, 1024, 2048, 1024); SetLastError(0xdeadbeef); firstret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents); firstGLE = GetLastError(); copy_compsA(&urlSrc, &urlComponents, 32, 0, 1024, 1024, 2048, 1024); SetLastError(0xdeadbeef); ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents); GLE = GetLastError(); ok(ret==firstret && (GLE==firstGLE), "InternetCrackUrl returned %d with GLE=%d (expected to return %d)\n", ret, GetLastError(), firstret); copy_compsA(&urlSrc, &urlComponents, 32, 1024, 0, 1024, 2048, 1024); SetLastError(0xdeadbeef); ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents); GLE = GetLastError(); ok(ret==firstret && (GLE==firstGLE), "InternetCrackUrl returned %d with GLE=%d (expected to return %d)\n", ret, GetLastError(), firstret); copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 0, 2048, 1024); SetLastError(0xdeadbeef); ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents); GLE = GetLastError(); ok(ret==firstret && (GLE==firstGLE), "InternetCrackUrl returned %d with GLE=%d (expected to return %d)\n", ret, GetLastError(), firstret); copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 0, 1024); SetLastError(0xdeadbeef); ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents); GLE = GetLastError(); todo_wine ok(ret==0 && (GLE==ERROR_INVALID_HANDLE || GLE==ERROR_INSUFFICIENT_BUFFER), "InternetCrackUrl returned %d with GLE=%d (expected to return 0 and ERROR_INVALID_HANDLE or ERROR_INSUFFICIENT_BUFFER)\n", ret, GLE); copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 0); SetLastError(0xdeadbeef); ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents); GLE = GetLastError(); todo_wine ok(ret==0 && (GLE==ERROR_INVALID_HANDLE || GLE==ERROR_INSUFFICIENT_BUFFER), "InternetCrackUrl returned %d with GLE=%d (expected to return 0 and ERROR_INVALID_HANDLE or ERROR_INSUFFICIENT_BUFFER)\n", ret, GLE); copy_compsA(&urlSrc, &urlComponents, 0, 0, 0, 0, 0, 0); ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents); GLE = GetLastError(); todo_wine ok(ret==0 && GLE==ERROR_INVALID_PARAMETER, "InternetCrackUrl returned %d with GLE=%d (expected to return 0 and ERROR_INVALID_PARAMETER)\n", ret, GLE); copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024); ret = InternetCrackUrl("about://host/blank", 0,0,&urlComponents); ok(ret, "InternetCrackUrl failed with %d\n", GetLastError()); ok(!strcmp(urlComponents.lpszScheme, "about"), "lpszScheme was \"%s\" instead of \"about\"\n", urlComponents.lpszScheme); ok(!strcmp(urlComponents.lpszHostName, "host"), "lpszHostName was \"%s\" instead of \"host\"\n", urlComponents.lpszHostName); ok(!strcmp(urlComponents.lpszUrlPath, "/blank"), "lpszUrlPath was \"%s\" instead of \"/blank\"\n", urlComponents.lpszUrlPath); /* try a NULL lpszUrl */ SetLastError(0xdeadbeef); copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024); ret = InternetCrackUrl(NULL, 0, 0, &urlComponents); GLE = GetLastError(); ok(ret == FALSE, "Expected InternetCrackUrl to fail\n"); ok(GLE == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GLE); /* try an empty lpszUrl, GetLastError returns 12006, whatever that means * we just need to fail and not return success */ SetLastError(0xdeadbeef); copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024); ret = InternetCrackUrl("", 0, 0, &urlComponents); GLE = GetLastError(); ok(ret == FALSE, "Expected InternetCrackUrl to fail\n"); ok(GLE != 0xdeadbeef && GLE != ERROR_SUCCESS, "Expected GLE to represent a failure\n"); /* Invalid Call: must set size of components structure (Windows only * enforces this on the InternetCrackUrlA version of the call) */ copy_compsA(&urlSrc, &urlComponents, 0, 1024, 1024, 1024, 2048, 1024); SetLastError(0xdeadbeef); urlComponents.dwStructSize = 0; ret = InternetCrackUrlA(TEST_URL, 0, 0, &urlComponents); ok(ret == FALSE, "Expected InternetCrackUrl to fail\n"); ok(GLE != 0xdeadbeef && GLE != ERROR_SUCCESS, "Expected GLE to represent a failure\n"); /* Invalid Call: size of dwStructSize must be one of the "standard" sizes * of the URL_COMPONENTS structure (Windows only enforces this on the * InternetCrackUrlA version of the call) */ copy_compsA(&urlSrc, &urlComponents, 0, 1024, 1024, 1024, 2048, 1024); SetLastError(0xdeadbeef); urlComponents.dwStructSize = sizeof(urlComponents) + 1; ret = InternetCrackUrlA(TEST_URL, 0, 0, &urlComponents); ok(ret == FALSE, "Expected InternetCrackUrl to fail\n"); ok(GLE != 0xdeadbeef && GLE != ERROR_SUCCESS, "Expected GLE to represent a failure\n"); }