ReactOS 0.4.17-dev-1190-g4c812f4
url.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "wininet.h"
#include "wine/test.h"
Include dependency graph for url.c:

Go to the source code of this file.

Classes

struct  crack_url_test_t
 

Macros

#define TEST_URL   "http://www.winehq.org/site/about#hi"
 
#define TEST_URL3   "file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml"
 
#define CREATE_URL1   "http://username:password@www.winehq.org/site/about"
 
#define CREATE_URL2   "http://username@www.winehq.org/site/about"
 
#define CREATE_URL3   "http://username:"
 
#define CREATE_URL4   "http://www.winehq.org/site/about"
 
#define CREATE_URL5   "http://"
 
#define CREATE_URL6   "nhttp://username:password@www.winehq.org:80/site/about"
 
#define CREATE_URL7   "http://username:password@www.winehq.org:42/site/about"
 
#define CREATE_URL8   "https://username:password@www.winehq.org/site/about"
 
#define CREATE_URL9   "about:blank"
 
#define CREATE_URL10   "about://host/blank"
 
#define CREATE_URL11   "about:"
 
#define CREATE_URL12   "http://www.winehq.org:65535"
 
#define CREATE_URL13   "http://localhost/?test=123"
 

Functions

static void copy_compsA (URL_COMPONENTSA *src, URL_COMPONENTSA *dst, DWORD scheLen, DWORD hostLen, DWORD userLen, DWORD passLen, DWORD pathLen, DWORD extrLen)
 
static void zero_compsA (URL_COMPONENTSA *dst, DWORD scheLen, DWORD hostLen, DWORD userLen, DWORD passLen, DWORD pathLen, DWORD extrLen)
 
static WCHAR * a2w (const char *str)
 
static int strcmp_wa (const WCHAR *str1, const char *str2)
 
static void test_crack_url (const crack_url_test_t *test)
 
static void test_long_url (void)
 
static void InternetCrackUrl_test (void)
 
static void InternetCrackUrlW_test (void)
 
static void fill_url_components (URL_COMPONENTSA *lpUrlComponents)
 
static void InternetCreateUrlA_test (void)
 
static void InternetCanonicalizeUrl_test (void)
 
 START_TEST (url)
 

Variables

static const crack_url_test_t crack_url_tests []
 

Macro Definition Documentation

◆ CREATE_URL1

#define CREATE_URL1   "http://username:password@www.winehq.org/site/about"

Definition at line 38 of file url.c.

◆ CREATE_URL10

#define CREATE_URL10   "about://host/blank"

Definition at line 47 of file url.c.

◆ CREATE_URL11

#define CREATE_URL11   "about:"

Definition at line 48 of file url.c.

◆ CREATE_URL12

#define CREATE_URL12   "http://www.winehq.org:65535"

Definition at line 49 of file url.c.

◆ CREATE_URL13

#define CREATE_URL13   "http://localhost/?test=123"

Definition at line 50 of file url.c.

◆ CREATE_URL2

#define CREATE_URL2   "http://username@www.winehq.org/site/about"

Definition at line 39 of file url.c.

◆ CREATE_URL3

#define CREATE_URL3   "http://username:"

Definition at line 40 of file url.c.

◆ CREATE_URL4

#define CREATE_URL4   "http://www.winehq.org/site/about"

Definition at line 41 of file url.c.

◆ CREATE_URL5

#define CREATE_URL5   "http://"

Definition at line 42 of file url.c.

◆ CREATE_URL6

#define CREATE_URL6   "nhttp://username:password@www.winehq.org:80/site/about"

Definition at line 43 of file url.c.

◆ CREATE_URL7

#define CREATE_URL7   "http://username:password@www.winehq.org:42/site/about"

Definition at line 44 of file url.c.

◆ CREATE_URL8

#define CREATE_URL8   "https://username:password@www.winehq.org/site/about"

Definition at line 45 of file url.c.

◆ CREATE_URL9

#define CREATE_URL9   "about:blank"

Definition at line 46 of file url.c.

◆ TEST_URL

#define TEST_URL   "http://www.winehq.org/site/about#hi"

Definition at line 35 of file url.c.

◆ TEST_URL3

#define TEST_URL3   "file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml"

Definition at line 36 of file url.c.

Function Documentation

◆ a2w()

static WCHAR * a2w ( const char *  str)
static

Definition at line 180 of file url.c.

181{
182 WCHAR *ret;
183 int len;
184
185 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
186 ret = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
188 return ret;
189}
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define MultiByteToWideChar
Definition: compat.h:110
return ret
Definition: mutex.c:147
GLenum GLsizei len
Definition: glext.h:6722
short WCHAR
Definition: pedump.c:58
const WCHAR * str

Referenced by strcmp_wa(), and test_crack_url().

◆ copy_compsA()

static void copy_compsA ( URL_COMPONENTSA *  src,
URL_COMPONENTSA *  dst,
DWORD  scheLen,
DWORD  hostLen,
DWORD  userLen,
DWORD  passLen,
DWORD  pathLen,
DWORD  extrLen 
)
static

Definition at line 52 of file url.c.

61{
62 *dst = *src;
63 dst->dwSchemeLength = scheLen;
64 dst->dwHostNameLength = hostLen;
65 dst->dwUserNameLength = userLen;
66 dst->dwPasswordLength = passLen;
67 dst->dwUrlPathLength = pathLen;
68 dst->dwExtraInfoLength = extrLen;
69 SetLastError(0xfaceabad);
70}
#define SetLastError(x)
Definition: compat.h:752
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

Referenced by InternetCrackUrl_test().

◆ fill_url_components()

static void fill_url_components ( URL_COMPONENTSA *  lpUrlComponents)
static

Definition at line 883 of file url.c.

884{
885 static CHAR http[] = "http",
886 winehq[] = "www.winehq.org",
887 username[] = "username",
888 password[] = "password",
889 site_about[] = "/site/about",
890 empty[] = "";
891
892 lpUrlComponents->dwStructSize = sizeof(URL_COMPONENTSA);
893 lpUrlComponents->lpszScheme = http;
894 lpUrlComponents->dwSchemeLength = strlen(lpUrlComponents->lpszScheme);
895 lpUrlComponents->nScheme = INTERNET_SCHEME_HTTP;
896 lpUrlComponents->lpszHostName = winehq;
897 lpUrlComponents->dwHostNameLength = strlen(lpUrlComponents->lpszHostName);
898 lpUrlComponents->nPort = 80;
899 lpUrlComponents->lpszUserName = username;
900 lpUrlComponents->dwUserNameLength = strlen(lpUrlComponents->lpszUserName);
901 lpUrlComponents->lpszPassword = password;
902 lpUrlComponents->dwPasswordLength = strlen(lpUrlComponents->lpszPassword);
903 lpUrlComponents->lpszUrlPath = site_about;
904 lpUrlComponents->dwUrlPathLength = strlen(lpUrlComponents->lpszUrlPath);
905 lpUrlComponents->lpszExtraInfo = empty;
906 lpUrlComponents->dwExtraInfoLength = strlen(lpUrlComponents->lpszExtraInfo);
907}
static UCHAR password[]
Definition: bcrypt.c:494
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
static WCHAR empty[]
Definition: url.c:28
static WCHAR http[]
Definition: url.c:30
static WCHAR winehq[]
Definition: url.c:31
static WCHAR username[]
Definition: url.c:32
char CHAR
Definition: pedump.c:57
INTERNET_SCHEME nScheme
Definition: wininet.h:196
LPSTR lpszScheme
Definition: wininet.h:194
DWORD dwSchemeLength
Definition: wininet.h:195
DWORD dwExtraInfoLength
Definition: wininet.h:207
DWORD dwUrlPathLength
Definition: wininet.h:205
DWORD dwStructSize
Definition: wininet.h:193
DWORD dwUserNameLength
Definition: wininet.h:201
LPSTR lpszExtraInfo
Definition: wininet.h:206
DWORD dwPasswordLength
Definition: wininet.h:203
LPSTR lpszPassword
Definition: wininet.h:202
LPSTR lpszUserName
Definition: wininet.h:200
DWORD dwHostNameLength
Definition: wininet.h:198
LPSTR lpszHostName
Definition: wininet.h:197
LPSTR lpszUrlPath
Definition: wininet.h:204
INTERNET_PORT nPort
Definition: wininet.h:199
#define INTERNET_SCHEME_HTTP
Definition: winhttp.h:47

◆ InternetCanonicalizeUrl_test()

static void InternetCanonicalizeUrl_test ( void  )
static

Definition at line 1251 of file url.c.

1252{
1253 char src[] = "http://www.winehq.org/%27/ /./>/#> ";
1254 char dst[64];
1255 DWORD dstlen;
1256
1257 dstlen = sizeof(dst);
1259 ok(strcmp(dst, "http://www.winehq.org/%27/%20/%3E/#>") == 0, "Got \"%s\"\n", dst);
1260
1261 /* despite what MSDN says, ICU_BROWSER_MODE seems to be ignored */
1262 dstlen = sizeof(dst);
1264 ok(strcmp(dst, "http://www.winehq.org/%27/%20/%3E/#>") == 0, "Got \"%s\"\n", dst);
1265
1266 /* ICU_ESCAPE is supposed to be ignored */
1267 dstlen = sizeof(dst);
1269 ok(strcmp(dst, "http://www.winehq.org/%27/%20/%3E/#>") == 0, "Got \"%s\"\n", dst);
1270
1271 dstlen = sizeof(dst);
1273 ok(strcmp(dst, "http://www.winehq.org/'/%20/%3E/#>") == 0, "Got \"%s\"\n", dst);
1274
1275 dstlen = sizeof(dst);
1277 ok(strcmp(dst, "http://www.winehq.org/%2527/%20/%3E/#>") == 0, "Got \"%s\"\n", dst);
1278
1279 dstlen = sizeof(dst);
1281 ok(strcmp(dst, "http://www.winehq.org/%27/%20/>/#>") == 0, "Got \"%s\"\n", dst);
1282
1283 dstlen = sizeof(dst);
1285 ok(strcmp(dst, "http://www.winehq.org/%27/ />/#>") == 0, "Got \"%s\"\n", dst);
1286
1287 dstlen = sizeof(dst);
1289 ok(strcmp(dst, "http://www.winehq.org/%27/%20/./%3E/#>") == 0, "Got \"%s\"\n", dst);
1290}
#define ok(value,...)
Definition: atltest.h:57
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
BOOL WINAPI InternetCanonicalizeUrlA(LPCSTR lpszUrl, LPSTR lpszBuffer, LPDWORD lpdwBufferLength, DWORD dwFlags)
Definition: internet.c:2411
unsigned long DWORD
Definition: ntddk_ex.h:95
static DWORD dstlen
Definition: directory.c:51
#define ICU_NO_META
Definition: winhttp.h:354
#define ICU_ENCODE_SPACES_ONLY
Definition: winhttp.h:355
#define ICU_DECODE
Definition: winhttp.h:353
#define ICU_BROWSER_MODE
Definition: winhttp.h:356
#define ICU_NO_ENCODE
Definition: winhttp.h:352
#define ICU_ESCAPE
Definition: winhttp.h:53
#define ICU_ENCODE_PERCENT
Definition: winhttp.h:357

Referenced by START_TEST().

◆ InternetCrackUrl_test()

static void InternetCrackUrl_test ( void  )
static

Definition at line 518 of file url.c.

519{
520 URL_COMPONENTSA urlSrc, urlComponents;
521 char protocol[32], hostName[1024], userName[1024];
522 char password[1024], extra[1024], path[1024];
523 BOOL ret, firstret;
524 DWORD GLE, firstGLE;
525
526 ZeroMemory(&urlSrc, sizeof(urlSrc));
527 urlSrc.dwStructSize = sizeof(urlSrc);
528 urlSrc.lpszScheme = protocol;
529 urlSrc.lpszHostName = hostName;
530 urlSrc.lpszUserName = userName;
531 urlSrc.lpszPassword = password;
532 urlSrc.lpszUrlPath = path;
533 urlSrc.lpszExtraInfo = extra;
534
535 /* Tests for lpsz* members pointing to real strings while
536 * some corresponding length members are set to zero.
537 * As of IE7 (wininet 7.0*?) all members are checked. So we
538 * run the first test and expect the outcome to be the same
539 * for the first four (scheme, hostname, username and password).
540 * The last two (path and extrainfo) are the same for all versions
541 * of the wininet.dll.
542 */
543 copy_compsA(&urlSrc, &urlComponents, 0, 1024, 1024, 1024, 1024, 1024);
544 SetLastError(0xdeadbeef);
545 firstret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents);
546 firstGLE = GetLastError();
547
548 copy_compsA(&urlSrc, &urlComponents, 32, 0, 1024, 1024, 1024, 1024);
549 SetLastError(0xdeadbeef);
550 ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents);
551 GLE = GetLastError();
552 ok(ret==firstret && (GLE==firstGLE), "InternetCrackUrl returned %d with GLE=%ld (expected to return %d)\n",
553 ret, GLE, firstret);
554
555 copy_compsA(&urlSrc, &urlComponents, 32, 1024, 0, 1024, 1024, 1024);
556 SetLastError(0xdeadbeef);
557 ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents);
558 GLE = GetLastError();
559 ok(ret==firstret && (GLE==firstGLE), "InternetCrackUrl returned %d with GLE=%ld (expected to return %d)\n",
560 ret, GLE, firstret);
561
562 copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 0, 1024, 1024);
563 SetLastError(0xdeadbeef);
564 ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents);
565 GLE = GetLastError();
566 ok(ret==firstret && (GLE==firstGLE), "InternetCrackUrl returned %d with GLE=%ld (expected to return %d)\n",
567 ret, GLE, firstret);
568
569 copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 0, 1024);
570 SetLastError(0xdeadbeef);
571 ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents);
572 GLE = GetLastError();
575 "InternetCrackUrl returned %d with GLE=%ld (expected to return 0 and ERROR_INVALID_HANDLE or ERROR_INSUFFICIENT_BUFFER)\n",
576 ret, GLE);
577
578 copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 1024, 0);
579 SetLastError(0xdeadbeef);
580 ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents);
581 GLE = GetLastError();
584 "InternetCrackUrl returned %d with GLE=%ld (expected to return 0 and ERROR_INVALID_HANDLE or ERROR_INSUFFICIENT_BUFFER)\n",
585 ret, GLE);
586
587 copy_compsA(&urlSrc, &urlComponents, 0, 0, 0, 0, 0, 0);
588 ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents);
589 GLE = GetLastError();
592 "InternetCrackUrl returned %d with GLE=%ld (expected to return 0 and ERROR_INVALID_PARAMETER)\n",
593 ret, GLE);
594
595 copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 1024, 1024);
596 ret = InternetCrackUrlA("about://host/blank", 0,0,&urlComponents);
597 ok(ret, "InternetCrackUrl failed with %ld\n", GetLastError());
598 ok(!strcmp(urlComponents.lpszScheme, "about"), "lpszScheme was \"%s\" instead of \"about\"\n", urlComponents.lpszScheme);
599 ok(!strcmp(urlComponents.lpszHostName, "host"), "lpszHostName was \"%s\" instead of \"host\"\n", urlComponents.lpszHostName);
600 ok(!strcmp(urlComponents.lpszUrlPath, "/blank"), "lpszUrlPath was \"%s\" instead of \"/blank\"\n", urlComponents.lpszUrlPath);
601
602 /* try a NULL lpszUrl */
603 SetLastError(0xdeadbeef);
604 copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 1024, 1024);
605 ret = InternetCrackUrlA(NULL, 0, 0, &urlComponents);
606 GLE = GetLastError();
607 ok(ret == FALSE, "Expected InternetCrackUrl to fail\n");
608 ok(GLE == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %ld\n", GLE);
609
610 /* try an empty lpszUrl, GetLastError returns 12006, whatever that means
611 * we just need to fail and not return success
612 */
613 SetLastError(0xdeadbeef);
614 copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 1024, 1024);
615 ret = InternetCrackUrlA("", 0, 0, &urlComponents);
616 GLE = GetLastError();
617 ok(ret == FALSE, "Expected InternetCrackUrl to fail\n");
618 ok(GLE != 0xdeadbeef && GLE != ERROR_SUCCESS, "Expected GLE to represent a failure\n");
619
620 /* Invalid Call: must set size of components structure (Windows only
621 * enforces this on the InternetCrackUrlA version of the call) */
622 copy_compsA(&urlSrc, &urlComponents, 0, 1024, 1024, 1024, 1024, 1024);
623 SetLastError(0xdeadbeef);
624 urlComponents.dwStructSize = 0;
625 ret = InternetCrackUrlA(TEST_URL, 0, 0, &urlComponents);
626 GLE = GetLastError();
627 ok(ret == FALSE, "Expected InternetCrackUrl to fail\n");
628 ok(GLE != 0xdeadbeef && GLE != ERROR_SUCCESS, "Expected GLE to represent a failure\n");
629
630 /* Invalid Call: size of dwStructSize must be one of the "standard" sizes
631 * of the URL_COMPONENTS structure (Windows only enforces this on the
632 * InternetCrackUrlA version of the call) */
633 copy_compsA(&urlSrc, &urlComponents, 0, 1024, 1024, 1024, 1024, 1024);
634 SetLastError(0xdeadbeef);
635 urlComponents.dwStructSize = sizeof(urlComponents) + 1;
636 ret = InternetCrackUrlA(TEST_URL, 0, 0, &urlComponents);
637 GLE = GetLastError();
638 ok(ret == FALSE, "Expected InternetCrackUrl to fail\n");
639 ok(GLE != 0xdeadbeef && GLE != ERROR_SUCCESS, "Expected GLE to represent a failure\n");
640
641 SetLastError(0xdeadbeef);
642 memset(&urlComponents, 0, sizeof(urlComponents));
643 urlComponents.dwStructSize = sizeof(urlComponents);
644 ret = InternetCrackUrlA("file.txt", 0, 0, &urlComponents);
645 GLE = GetLastError();
646 ok(ret == FALSE, "Expected InternetCrackUrl to fail\n");
647 ok(GLE == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "Expected GLE to represent a failure\n");
648
649 SetLastError(0xdeadbeef);
650 memset(&urlComponents, 0, sizeof(urlComponents));
651 urlComponents.dwStructSize = sizeof(urlComponents);
652 ret = InternetCrackUrlA("www.winehq.org", 0, 0, &urlComponents);
653 GLE = GetLastError();
654 ok(ret == FALSE, "Expected InternetCrackUrl to fail\n");
655 ok(GLE == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "Expected GLE to represent a failure\n");
656
657 /* Windows treats dwUrlLength as a maximum - if there is a null before
658 * that length, it stops there. */
659 copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 1024, 1024);
660 ret = InternetCrackUrlA("http://x.org", 13 /* includes the nul */, 0, &urlComponents);
661 ok(ret, "InternetCrackUrlA failed with error %ld\n", GetLastError());
662 ok(urlComponents.dwHostNameLength == 5,
663 "Expected dwHostNameLength of 5, got %ld\n", urlComponents.dwHostNameLength);
664
665 copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 1024, 1024);
666 ret = InternetCrackUrlA("http://\0x.org", 13, 0, &urlComponents);
667 todo_wine ok(ret == FALSE, "Expected InternetCrackUrlA to fail\n");
668
669 copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 1024, 1024);
670 ret = InternetCrackUrlA("http://x.org\0/x", 15, 0, &urlComponents);
671 ok(ret, "InternetCrackUrlA failed with error %ld\n", GetLastError());
672 ok(urlComponents.dwUrlPathLength == 0,
673 "Expected dwUrlPathLength of 0, got %ld\n", urlComponents.dwUrlPathLength);
674}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_SUCCESS
Definition: deptool.c:10
#define FALSE
Definition: types.h:117
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
BOOL WINAPI InternetCrackUrlA(const char *url, DWORD url_length, DWORD flags, URL_COMPONENTSA *ret_comp)
Definition: internet.c:1933
unsigned int BOOL
Definition: ntddk_ex.h:94
@ extra
Definition: id3.c:95
#define todo_wine
Definition: minitest.h:80
#define ZeroMemory
Definition: minwinbase.h:31
static DWORD GLE
Definition: registry.c:54
static void copy_compsA(URL_COMPONENTSA *src, URL_COMPONENTSA *dst, DWORD scheLen, DWORD hostLen, DWORD userLen, DWORD passLen, DWORD pathLen, DWORD extrLen)
Definition: url.c:52
#define TEST_URL
Definition: url.c:35
#define TEST_URL3
Definition: url.c:36
#define memset(x, y, z)
Definition: compat.h:39
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_INTERNET_UNRECOGNIZED_SCHEME
Definition: wininet.h:1995
static const WCHAR userName[]
Definition: wnet.c:2156

Referenced by START_TEST().

◆ InternetCrackUrlW_test()

static void InternetCrackUrlW_test ( void  )
static

Definition at line 676 of file url.c.

677{
678 WCHAR url[] = {
679 'h','t','t','p',':','/','/','1','9','2','.','1','6','8','.','0','.','2','2','/',
680 'C','F','I','D','E','/','m','a','i','n','.','c','f','m','?','C','F','S','V','R',
681 '=','I','D','E','&','A','C','T','I','O','N','=','I','D','E','_','D','E','F','A',
682 'U','L','T', 0 };
683 static const WCHAR url2[] = { '.','.','/','R','i','t','z','.','x','m','l',0 };
684 static const WCHAR url3[] = { 'h','t','t','p',':','/','/','x','.','o','r','g',0 };
685 static const WCHAR url4[] = { 'h','t','t','p',':','/','/',0,'x','.','o','r','g',0 };
686 static const WCHAR url5[] = { 'h','t','t','p',':','/','/','x','.','o','r','g',0,'/','x',0 };
687 URL_COMPONENTSW comp;
688 WCHAR scheme[20], host[20], user[20], pwd[20], urlpart[50], extra[50];
689 DWORD error;
690 BOOL r;
691
692 urlpart[0]=0;
693 scheme[0]=0;
694 extra[0]=0;
695 host[0]=0;
696 user[0]=0;
697 pwd[0]=0;
698 memset(&comp, 0, sizeof comp);
699 comp.dwStructSize = sizeof(comp);
700 comp.lpszScheme = scheme;
702 comp.lpszHostName = host;
704 comp.lpszUserName = user;
706 comp.lpszPassword = pwd;
708 comp.lpszUrlPath = urlpart;
709 comp.dwUrlPathLength = ARRAY_SIZE(urlpart);
710 comp.lpszExtraInfo = extra;
712
713 SetLastError(0xdeadbeef);
714 r = InternetCrackUrlW(NULL, 0, 0, &comp );
717 {
718 win_skip("InternetCrackUrlW is not implemented\n");
719 return;
720 }
721 ok( !r, "InternetCrackUrlW succeeded unexpectedly\n");
724 "expected ERROR_INVALID_PARAMETER got %lu\n", error);
725
727 {
728 /* Crashes on IE5 */
729 SetLastError(0xdeadbeef);
730 r = InternetCrackUrlW(url, 0, 0, NULL );
732 ok( !r, "InternetCrackUrlW succeeded unexpectedly\n");
733 ok( error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %lu\n", error);
734 }
735
736 r = InternetCrackUrlW(url, 0, 0, &comp );
737 ok( r, "failed to crack url\n");
738 ok( comp.dwSchemeLength == 4, "scheme length wrong\n");
739 ok( comp.dwHostNameLength == 12, "host length wrong\n");
740 ok( comp.dwUserNameLength == 0, "user length wrong\n");
741 ok( comp.dwPasswordLength == 0, "password length wrong\n");
742 ok( comp.dwUrlPathLength == 15, "url length wrong\n");
743 ok( comp.dwExtraInfoLength == 29, "extra length wrong\n");
744
745 urlpart[0]=0;
746 host[0]=0;
747 memset(&comp, 0, sizeof comp);
748 comp.dwStructSize = sizeof comp;
749 comp.lpszHostName = host;
751 comp.lpszUrlPath = urlpart;
752 comp.dwUrlPathLength = ARRAY_SIZE(urlpart);
753
754 r = InternetCrackUrlW(url, 0, 0, &comp );
755 ok( r, "failed to crack url\n");
756 ok( comp.dwSchemeLength == 0, "scheme length wrong\n");
757 ok( comp.dwHostNameLength == 12, "host length wrong\n");
758 ok( comp.dwUserNameLength == 0, "user length wrong\n");
759 ok( comp.dwPasswordLength == 0, "password length wrong\n");
760 ok( comp.dwUrlPathLength == 44, "url length wrong\n");
761 ok( comp.dwExtraInfoLength == 0, "extra length wrong\n");
762
763 urlpart[0]=0;
764 host[0]=0;
765 memset(&comp, 0, sizeof comp);
766 comp.dwStructSize = sizeof comp;
767 comp.lpszHostName = host;
769 comp.lpszUrlPath = urlpart;
770 comp.dwUrlPathLength = ARRAY_SIZE(urlpart);
771 comp.lpszExtraInfo = NULL;
773
774 r = InternetCrackUrlW(url, 0, 0, &comp );
775 ok( r, "failed to crack url\n");
776 ok( comp.dwSchemeLength == 0, "scheme length wrong\n");
777 ok( comp.dwHostNameLength == 12, "host length wrong\n");
778 ok( comp.dwUserNameLength == 0, "user length wrong\n");
779 ok( comp.dwPasswordLength == 0, "password length wrong\n");
780 ok( comp.dwUrlPathLength == 15, "url length wrong\n");
781 ok( comp.dwExtraInfoLength == 29, "extra length wrong\n");
782
783 urlpart[0]=0;
784 scheme[0]=0;
785 extra[0]=0;
786 host[0]=0;
787 user[0]=0;
788 pwd[0]=0;
789 memset(&comp, 0, sizeof(comp));
790 comp.dwStructSize = sizeof(comp);
791 comp.lpszScheme = scheme;
793 comp.lpszHostName = host;
795 comp.lpszUserName = user;
797 comp.lpszPassword = pwd;
799 comp.lpszUrlPath = urlpart;
800 comp.dwUrlPathLength = ARRAY_SIZE(urlpart);
801 comp.lpszExtraInfo = extra;
803
804 r = InternetCrackUrlW(url2, 0, 0, &comp);
805 ok(!r, "InternetCrackUrl should have failed\n");
807 "InternetCrackUrl should have failed with error ERROR_INTERNET_UNRECOGNIZED_SCHEME instead of error %ld\n",
808 GetLastError());
809
810 /* Test to see whether cracking a URL without a filename initializes urlpart */
811 urlpart[0]=0xba;
812 scheme[0]=0;
813 extra[0]=0;
814 host[0]=0;
815 user[0]=0;
816 pwd[0]=0;
817 memset(&comp, 0, sizeof comp);
818 comp.dwStructSize = sizeof comp;
819 comp.lpszScheme = scheme;
821 comp.lpszHostName = host;
823 comp.lpszUserName = user;
825 comp.lpszPassword = pwd;
827 comp.lpszUrlPath = urlpart;
828 comp.dwUrlPathLength = ARRAY_SIZE(urlpart);
829 comp.lpszExtraInfo = extra;
831 r = InternetCrackUrlW(url3, 0, 0, &comp );
832 ok( r, "InternetCrackUrlW failed unexpectedly\n");
833 ok( host[0] == 'x', "host should be x.org\n");
834 ok( urlpart[0] == 0, "urlpart should be empty\n");
835
836 urlpart[0] = 0;
837 host[0] = 0;
838 memset(&comp, 0, sizeof(comp));
839 comp.dwStructSize = sizeof(comp);
840 comp.lpszHostName = host;
842 comp.lpszUrlPath = urlpart;
843 comp.dwUrlPathLength = ARRAY_SIZE(urlpart);
844 r = InternetCrackUrlW(url3, 0, ICU_DECODE, &comp);
845 ok(r, "InternetCrackUrlW failed unexpectedly\n");
846 ok(!strcmp_wa(host, "x.org"), "host is %s, should be x.org\n", wine_dbgstr_w(host));
847 todo_wine ok(urlpart[0] == 0, "urlpart should be empty\n");
848
849 /* Windows treats dwUrlLength as a maximum - if there is a null before
850 * that length, it stops there. */
851 host[0] = 0;
852 memset(&comp, 0, sizeof(comp));
853 comp.dwStructSize = sizeof(comp);
854 comp.lpszHostName = host;
856 r = InternetCrackUrlW(url3, 13 /* includes the nul */, 0, &comp);
857 ok(r, "InternetCrackUrlW failed with error %ld\n", GetLastError());
858 ok(comp.dwHostNameLength == 5,
859 "Expected dwHostNameLength of 5, got %ld\n", comp.dwHostNameLength);
860
861 host[0] = 0;
862 memset(&comp, 0, sizeof(comp));
863 comp.dwStructSize = sizeof(comp);
864 comp.lpszHostName = host;
866 r = InternetCrackUrlW(url4, 13, 0, &comp);
867 todo_wine ok(r == FALSE, "Expected InternetCrackUrlW to fail\n");
868
869 host[0] = 0;
870 urlpart[0] = 0;
871 memset(&comp, 0, sizeof(comp));
872 comp.dwStructSize = sizeof(comp);
873 comp.lpszHostName = host;
875 comp.lpszUrlPath = urlpart;
876 comp.dwUrlPathLength = ARRAY_SIZE(urlpart);
877 r = InternetCrackUrlW(url5, 15, 0, &comp);
878 ok(r, "InternetCrackUrlW failed with error %ld\n", GetLastError());
879 ok(comp.dwUrlPathLength == 0,
880 "Expected dwUrlPathLength of 0, got %ld\n", comp.dwUrlPathLength);
881}
#define broken(x)
Definition: atltest.h:178
void user(int argc, const char *argv[])
Definition: cmds.c:1350
#define ARRAY_SIZE(A)
Definition: main.h:20
UCHAR * pwd
Definition: bcrypt.c:515
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
BOOL WINAPI InternetCrackUrlW(const WCHAR *lpszUrl, DWORD dwUrlLength, DWORD dwFlags, URL_COMPONENTSW *lpUC)
Definition: internet.c:2052
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define wine_dbgstr_w
Definition: kernel32.h:34
#define win_skip
Definition: minitest.h:67
#define error(str)
Definition: mkdosfs.c:1605
static const WCHAR url[]
Definition: encode.c:1384
static const WCHAR url2[]
Definition: misc.c:279
static const WCHAR url5[]
Definition: url.c:46
static const WCHAR url4[]
Definition: url.c:45
static const WCHAR url3[]
Definition: url.c:44
static int strcmp_wa(const WCHAR *str1, const char *str2)
Definition: url.c:191
DWORD scheme
DWORD dwStructSize
Definition: wininet.h:211
DWORD dwUrlPathLength
Definition: wininet.h:223
DWORD dwExtraInfoLength
Definition: wininet.h:225
LPWSTR lpszPassword
Definition: wininet.h:220
LPWSTR lpszHostName
Definition: wininet.h:215
DWORD dwUserNameLength
Definition: wininet.h:219
DWORD dwHostNameLength
Definition: wininet.h:216
LPWSTR lpszScheme
Definition: wininet.h:212
LPWSTR lpszUserName
Definition: wininet.h:218
LPWSTR lpszUrlPath
Definition: wininet.h:222
LPWSTR lpszExtraInfo
Definition: wininet.h:224
DWORD dwPasswordLength
Definition: wininet.h:221
DWORD dwSchemeLength
Definition: wininet.h:213
Definition: txthost.c:37

Referenced by START_TEST().

◆ InternetCreateUrlA_test()

static void InternetCreateUrlA_test ( void  )
static

Definition at line 909 of file url.c.

910{
911 URL_COMPONENTSA urlComp;
912 LPSTR szUrl;
913 DWORD len = -1;
914 BOOL ret;
915 static CHAR empty[] = "",
916 nhttp[] = "nhttp",
917 http[] = "http",
918 https[] = "https",
919 winehq[] = "www.winehq.org",
920 localhost[] = "localhost",
921 username[] = "username",
922 password[] = "password",
923 root[] = "/",
924 site_about[] = "/site/about",
925 extra_info[] = "?test=123",
926 about[] = "about",
927 blank[] = "blank",
928 host[] = "host";
929
930 /* test NULL lpUrlComponents */
931 SetLastError(0xdeadbeef);
933 ok(!ret, "Expected failure\n");
935 "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
936 ok(len == -1, "Expected len -1, got %ld\n", len);
937
938 /* test zero'ed lpUrlComponents */
939 ZeroMemory(&urlComp, sizeof(urlComp));
940 SetLastError(0xdeadbeef);
941 ret = InternetCreateUrlA(&urlComp, 0, NULL, &len);
942 ok(!ret, "Expected failure\n");
944 "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
945 ok(len == -1, "Expected len -1, got %ld\n", len);
946
947 /* test valid lpUrlComponents, NULL lpdwUrlLength */
948 fill_url_components(&urlComp);
949 SetLastError(0xdeadbeef);
950 ret = InternetCreateUrlA(&urlComp, 0, NULL, NULL);
951 ok(!ret, "Expected failure\n");
953 "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
954
955 /* test valid lpUrlComponents, empty szUrl
956 * lpdwUrlLength is size of buffer required on exit, including
957 * the terminating null when GLE == ERROR_INSUFFICIENT_BUFFER
958 */
959 SetLastError(0xdeadbeef);
960 ret = InternetCreateUrlA(&urlComp, 0, NULL, &len);
961 ok(!ret, "Expected failure\n");
963 "Expected ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
964 ok(len == 51, "Expected len 51, got %ld\n", len);
965
966 /* test correct size, NULL szUrl */
967 fill_url_components(&urlComp);
968 SetLastError(0xdeadbeef);
969 ret = InternetCreateUrlA(&urlComp, 0, NULL, &len);
970 ok(!ret, "Expected failure\n");
972 "Expected ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
973 ok(len == 51, "Expected len 51, got %ld\n", len);
974
975 /* test valid lpUrlComponents, alloc-ed szUrl, small size */
976 SetLastError(0xdeadbeef);
977 szUrl = HeapAlloc(GetProcessHeap(), 0, len);
978 len -= 2;
979 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
980 ok(!ret, "Expected failure\n");
982 "Expected ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
983 ok(len == 51, "Expected len 51, got %ld\n", len);
984
985 /* alloc-ed szUrl, NULL lpszScheme
986 * shows that it uses nScheme instead
987 */
988 urlComp.lpszScheme = NULL;
989 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
990 ok(ret, "Expected success\n");
991 ok(len == 50, "Expected len 50, got %ld\n", len);
992 ok(!strcmp(szUrl, CREATE_URL1), "Expected %s, got %s\n", CREATE_URL1, szUrl);
993
994 /* alloc-ed szUrl, invalid nScheme
995 * any nScheme out of range seems ignored
996 */
997 fill_url_components(&urlComp);
998 urlComp.nScheme = -3;
999 len++;
1000 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
1001 ok(ret, "Expected success\n");
1002 ok(len == 50, "Expected len 50, got %ld\n", len);
1003
1004 /* test valid lpUrlComponents, alloc-ed szUrl */
1005 fill_url_components(&urlComp);
1006 len = 51;
1007 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
1008 ok(ret, "Expected success\n");
1009 ok(len == 50, "Expected len 50, got %ld\n", len);
1010 ok(strstr(szUrl, "80") == NULL, "Didn't expect to find 80 in szUrl\n");
1011 ok(!strcmp(szUrl, CREATE_URL1), "Expected %s, got %s\n", CREATE_URL1, szUrl);
1012
1013 /* valid username, NULL password */
1014 fill_url_components(&urlComp);
1015 urlComp.lpszPassword = NULL;
1016 len = 42;
1017 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
1018 ok(ret, "Expected success\n");
1019 ok(len == 41, "Expected len 41, got %ld\n", len);
1020 ok(!strcmp(szUrl, CREATE_URL2), "Expected %s, got %s\n", CREATE_URL2, szUrl);
1021
1022 /* valid username, empty password */
1023 fill_url_components(&urlComp);
1024 urlComp.lpszPassword = empty;
1025 len = 51;
1026 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
1027 ok(ret, "Expected success\n");
1028 ok(len == 50, "Expected len 50, got %ld\n", len);
1029 ok(!strcmp(szUrl, CREATE_URL3), "Expected %s, got %s\n", CREATE_URL3, szUrl);
1030
1031 /* valid password, NULL username
1032 * if password is provided, username has to exist
1033 */
1034 fill_url_components(&urlComp);
1035 SetLastError(0xdeadbeef);
1036 urlComp.lpszUserName = NULL;
1037 len = 42;
1038 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
1039 ok(!ret, "Expected failure\n");
1041 "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
1042 ok(len == 42, "Expected len 42, got %ld\n", len);
1043 ok(!strcmp(szUrl, CREATE_URL3), "Expected %s, got %s\n", CREATE_URL3, szUrl);
1044
1045 /* valid password, empty username
1046 * if password is provided, username has to exist
1047 */
1048 fill_url_components(&urlComp);
1049 urlComp.lpszUserName = empty;
1050 len = 51;
1051 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
1052 ok(ret, "Expected success\n");
1053 ok(len == 50, "Expected len 50, got %ld\n", len);
1054 ok(!strcmp(szUrl, CREATE_URL5), "Expected %s, got %s\n", CREATE_URL5, szUrl);
1055
1056 /* NULL username, NULL password */
1057 fill_url_components(&urlComp);
1058 urlComp.lpszUserName = NULL;
1059 urlComp.lpszPassword = NULL;
1060 len = 42;
1061 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
1062 ok(ret, "Expected success\n");
1063 ok(len == 32, "Expected len 32, got %ld\n", len);
1064 ok(!strcmp(szUrl, CREATE_URL4), "Expected %s, got %s\n", CREATE_URL4, szUrl);
1065
1066 /* empty username, empty password */
1067 fill_url_components(&urlComp);
1068 urlComp.lpszUserName = empty;
1069 urlComp.lpszPassword = empty;
1070 len = 51;
1071 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
1072 ok(ret, "Expected success\n");
1073 ok(len == 50, "Expected len 50, got %ld\n", len);
1074 ok(!strcmp(szUrl, CREATE_URL5), "Expected %s, got %s\n", CREATE_URL5, szUrl);
1075
1076 /* shows that nScheme is ignored, as the appearance of the port number
1077 * depends on lpszScheme and the string copied depends on lpszScheme.
1078 */
1079 fill_url_components(&urlComp);
1080 HeapFree(GetProcessHeap(), 0, szUrl);
1081 urlComp.lpszScheme = nhttp;
1082 urlComp.dwSchemeLength = strlen(urlComp.lpszScheme);
1083 len = strlen(CREATE_URL6) + 1;
1084 szUrl = HeapAlloc(GetProcessHeap(), 0, len);
1085 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1086 ok(ret, "Expected success\n");
1087 ok(len == strlen(CREATE_URL6), "Expected len %Iu, got %ld\n", strlen(CREATE_URL6) + 1, len);
1088 ok(!strcmp(szUrl, CREATE_URL6), "Expected %s, got %s\n", CREATE_URL6, szUrl);
1089
1090 /* if lpszScheme != "http" or nPort != 80, display nPort */
1091 HeapFree(GetProcessHeap(), 0, szUrl);
1092 urlComp.lpszScheme = http;
1093 urlComp.dwSchemeLength = strlen(urlComp.lpszScheme);
1094 urlComp.nPort = 42;
1095 szUrl = HeapAlloc(GetProcessHeap(), 0, ++len);
1096 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1097 ok(ret, "Expected success\n");
1098 ok(len == 53, "Expected len 53, got %ld\n", len);
1099 ok(strstr(szUrl, "42") != NULL, "Expected to find 42 in szUrl\n");
1100 ok(!strcmp(szUrl, CREATE_URL7), "Expected %s, got %s\n", CREATE_URL7, szUrl);
1101
1102 HeapFree(GetProcessHeap(), 0, szUrl);
1103
1104 memset(&urlComp, 0, sizeof(urlComp));
1105 urlComp.dwStructSize = sizeof(urlComp);
1106 urlComp.lpszScheme = http;
1107 urlComp.dwSchemeLength = 0;
1108 urlComp.nScheme = INTERNET_SCHEME_HTTP;
1109 urlComp.lpszHostName = winehq;
1110 urlComp.dwHostNameLength = 0;
1111 urlComp.nPort = 80;
1112 urlComp.lpszUserName = username;
1113 urlComp.dwUserNameLength = 0;
1114 urlComp.lpszPassword = password;
1115 urlComp.dwPasswordLength = 0;
1116 urlComp.lpszUrlPath = site_about;
1117 urlComp.dwUrlPathLength = 0;
1118 urlComp.lpszExtraInfo = empty;
1119 urlComp.dwExtraInfoLength = 0;
1121 szUrl = HeapAlloc(GetProcessHeap(), 0, ++len);
1122 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1123 ok(ret, "Expected success\n");
1124 ok(len == strlen(CREATE_URL1), "Expected len %Iu, got %ld\n", strlen(CREATE_URL1), len);
1125 ok(!strcmp(szUrl, CREATE_URL1), "Expected %s, got %s\n", CREATE_URL1, szUrl);
1126
1127 HeapFree(GetProcessHeap(), 0, szUrl);
1128
1129 memset(&urlComp, 0, sizeof(urlComp));
1130 urlComp.dwStructSize = sizeof(urlComp);
1131 urlComp.lpszScheme = https;
1132 urlComp.dwSchemeLength = 0;
1133 urlComp.nScheme = INTERNET_SCHEME_HTTP;
1134 urlComp.lpszHostName = winehq;
1135 urlComp.dwHostNameLength = 0;
1136 urlComp.nPort = 443;
1137 urlComp.lpszUserName = username;
1138 urlComp.dwUserNameLength = 0;
1139 urlComp.lpszPassword = password;
1140 urlComp.dwPasswordLength = 0;
1141 urlComp.lpszUrlPath = site_about;
1142 urlComp.dwUrlPathLength = 0;
1143 urlComp.lpszExtraInfo = empty;
1144 urlComp.dwExtraInfoLength = 0;
1146 szUrl = HeapAlloc(GetProcessHeap(), 0, ++len);
1147 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1148 ok(ret, "Expected success\n");
1149 ok(len == strlen(CREATE_URL8), "Expected len %Iu, got %ld\n", strlen(CREATE_URL8), len);
1150 ok(!strcmp(szUrl, CREATE_URL8), "Expected %s, got %s\n", CREATE_URL8, szUrl);
1151
1152 HeapFree(GetProcessHeap(), 0, szUrl);
1153
1154 memset(&urlComp, 0, sizeof(urlComp));
1155 urlComp.dwStructSize = sizeof(urlComp);
1156 urlComp.lpszScheme = about;
1157 urlComp.dwSchemeLength = 5;
1158 urlComp.lpszUrlPath = blank;
1159 urlComp.dwUrlPathLength = 5;
1161 len++; /* work around bug in native wininet */
1162 szUrl = HeapAlloc(GetProcessHeap(), 0, ++len);
1163 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1164 ok(ret, "Expected success\n");
1165 ok(len == strlen(CREATE_URL9), "Expected len %Iu, got %ld\n", strlen(CREATE_URL9), len);
1166 ok(!strcmp(szUrl, CREATE_URL9), "Expected %s, got %s\n", CREATE_URL9, szUrl);
1167
1168 HeapFree(GetProcessHeap(), 0, szUrl);
1169
1170 memset(&urlComp, 0, sizeof(urlComp));
1171 urlComp.dwStructSize = sizeof(urlComp);
1172 urlComp.lpszScheme = about;
1173 urlComp.lpszHostName = host;
1174 urlComp.lpszUrlPath = blank;
1176 len++; /* work around bug in native wininet */
1177 szUrl = HeapAlloc(GetProcessHeap(), 0, ++len);
1178 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1179 ok(ret, "Expected success\n");
1180 ok(len == strlen(CREATE_URL10), "Expected len %Iu, got %ld\n", strlen(CREATE_URL10), len);
1181 ok(!strcmp(szUrl, CREATE_URL10), "Expected %s, got %s\n", CREATE_URL10, szUrl);
1182
1183 HeapFree(GetProcessHeap(), 0, szUrl);
1184
1185 memset(&urlComp, 0, sizeof(urlComp));
1186 urlComp.dwStructSize = sizeof(urlComp);
1187 urlComp.nPort = 8080;
1188 urlComp.lpszScheme = about;
1190 szUrl = HeapAlloc(GetProcessHeap(), 0, ++len);
1191 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1192 ok(ret, "Expected success\n");
1193 ok(len == strlen(CREATE_URL11), "Expected len %Iu, got %ld\n", strlen(CREATE_URL11), len);
1194 ok(!strcmp(szUrl, CREATE_URL11), "Expected %s, got %s\n", CREATE_URL11, szUrl);
1195
1196 HeapFree(GetProcessHeap(), 0, szUrl);
1197
1198 memset(&urlComp, 0, sizeof(urlComp));
1199 urlComp.dwStructSize = sizeof(urlComp);
1200 urlComp.lpszScheme = http;
1201 urlComp.dwSchemeLength = 0;
1202 urlComp.nScheme = INTERNET_SCHEME_HTTP;
1203 urlComp.lpszHostName = winehq;
1204 urlComp.dwHostNameLength = 0;
1205 urlComp.nPort = 65535;
1207 szUrl = HeapAlloc(GetProcessHeap(), 0, ++len);
1208 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1209 ok(ret, "Expected success\n");
1210 ok(len == strlen(CREATE_URL12), "Expected len %Iu, got %ld\n", strlen(CREATE_URL12), len);
1211 ok(!strcmp(szUrl, CREATE_URL12), "Expected %s, got %s\n", CREATE_URL12, szUrl);
1212
1213 HeapFree(GetProcessHeap(), 0, szUrl);
1214
1215 memset(&urlComp, 0, sizeof(urlComp));
1216 urlComp.dwStructSize = sizeof(urlComp);
1217 urlComp.lpszScheme = http;
1218 urlComp.dwSchemeLength = strlen(urlComp.lpszScheme);
1219 urlComp.lpszHostName = localhost;
1220 urlComp.dwHostNameLength = strlen(urlComp.lpszHostName);
1221 urlComp.nPort = 80;
1222 urlComp.lpszUrlPath = root;
1223 urlComp.dwUrlPathLength = strlen(urlComp.lpszUrlPath);
1224 urlComp.lpszExtraInfo = extra_info;
1225 urlComp.dwExtraInfoLength = strlen(urlComp.lpszExtraInfo);
1226 len = 256;
1227 szUrl = HeapAlloc(GetProcessHeap(), 0, len);
1228 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1229 ok(ret, "Expected success\n");
1230 ok(len == strlen(CREATE_URL13), "Got len %lu\n", len);
1231 ok(!strcmp(szUrl, CREATE_URL13), "Expected \"%s\", got \"%s\"\n", CREATE_URL13, szUrl);
1232
1233 HeapFree(GetProcessHeap(), 0, szUrl);
1234
1235 memset(&urlComp, 0, sizeof(urlComp));
1236 fill_url_components(&urlComp);
1237 urlComp.lpszScheme = NULL;
1238 urlComp.dwSchemeLength = 0;
1240 len = 256;
1241 szUrl = HeapAlloc(GetProcessHeap(), 0, len);
1242 SetLastError(0xdeadbeef);
1243 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
1244 ok(!ret, "Expected failure\n");
1246 "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
1247
1248 HeapFree(GetProcessHeap(), 0, szUrl);
1249}
struct _root root
#define HeapFree(x, y, z)
Definition: compat.h:735
_ACRTIMP char *__cdecl strstr(const char *, const char *)
Definition: string.c:3420
BOOL WINAPI InternetCreateUrlA(LPURL_COMPONENTSA lpUrlComponents, DWORD dwFlags, LPSTR lpszUrl, LPDWORD lpdwUrlLength)
Definition: internet.c:4986
static const BYTE localhost[]
Definition: encode.c:1391
static void fill_url_components(URL_COMPONENTS *uc)
Definition: url.c:77
static WCHAR about[]
Definition: url.c:34
#define CREATE_URL9
Definition: url.c:46
#define CREATE_URL2
Definition: url.c:39
#define CREATE_URL13
Definition: url.c:50
#define CREATE_URL8
Definition: url.c:45
#define CREATE_URL7
Definition: url.c:44
#define CREATE_URL11
Definition: url.c:48
#define CREATE_URL1
Definition: url.c:38
#define CREATE_URL3
Definition: url.c:40
#define CREATE_URL4
Definition: url.c:41
#define CREATE_URL10
Definition: url.c:47
#define CREATE_URL6
Definition: url.c:43
#define CREATE_URL5
Definition: url.c:42
#define CREATE_URL12
Definition: url.c:49
char * LPSTR
Definition: typedefs.h:51
@ INTERNET_SCHEME_UNKNOWN
Definition: wininet.h:137

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( url  )

Definition at line 1292 of file url.c.

1293{
1294 int i;
1295
1296 if(!GetProcAddress(GetModuleHandleA("wininet.dll"), "InternetGetCookieExW")) {
1297 win_skip("Too old IE (older than 6.0)\n");
1298 return;
1299 }
1300
1301 for(i = 0; i < ARRAY_SIZE(crack_url_tests); i++)
1303
1304 test_long_url();
1305
1310}
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static void InternetCrackUrlW_test(void)
Definition: url.c:676
static const crack_url_test_t crack_url_tests[]
Definition: url.c:117
static void test_crack_url(const crack_url_test_t *test)
Definition: url.c:199
static void InternetCreateUrlA_test(void)
Definition: url.c:909
static void InternetCrackUrl_test(void)
Definition: url.c:518
static void test_long_url(void)
Definition: url.c:481
static void InternetCanonicalizeUrl_test(void)
Definition: url.c:1251

◆ strcmp_wa()

static int strcmp_wa ( const WCHAR *  str1,
const char *  str2 
)
static

Definition at line 191 of file url.c.

192{
193 WCHAR *str2w = a2w(str2);
194 int ret = lstrcmpW(str1, str2w);
195 HeapFree(GetProcessHeap(), 0, str2w);
196 return ret;
197}
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
static WCHAR * a2w(const char *str)
Definition: url.c:180
XML_HIDDEN void xmlParserErrors const char const xmlChar const xmlChar * str2
Definition: parser.h:35
XML_HIDDEN void xmlParserErrors const char const xmlChar * str1
Definition: parser.h:35

Referenced by InternetCrackUrlW_test(), and test_crack_url().

◆ test_crack_url()

static void test_crack_url ( const crack_url_test_t *  test)
static

Definition at line 199 of file url.c.

200{
201 URL_COMPONENTSW urlw;
203 char *scheme_a, *hostname_a, *username_a;
204 char *password_a, *extrainfo_a, *urlpath_a;
205 WCHAR *scheme_w, *hostname_w, *username_w;
206 WCHAR *password_w, *extrainfo_w, *urlpath_w;
207 size_t buf_len = strlen(test->url);
208 WCHAR *buf;
209 BOOL b;
210
211 /* test InternetCrackUrlA with NULL buffers */
212 zero_compsA(&url, 1, 1, 1, 1, 1, 1);
213
214 b = InternetCrackUrlA(test->url, strlen(test->url), 0, &url);
215 ok(b, "InternetCrackUrl failed with error %ld\n", GetLastError());
216
217 if(test->scheme_off == -1)
218 ok(!url.lpszScheme, "[%s] url.lpszScheme = %p, expected NULL\n", test->url, url.lpszScheme);
219 else
220 ok(url.lpszScheme == test->url+test->scheme_off, "[%s] url.lpszScheme = %p, expected %p\n",
221 test->url, url.lpszScheme, test->url+test->scheme_off);
222 ok(url.dwSchemeLength == test->scheme_len, "[%s] url.lpszSchemeLength = %ld, expected %d\n",
223 test->url, url.dwSchemeLength, test->scheme_len);
224
225 ok(url.nScheme == test->scheme, "[%s] url.nScheme = %d, expected %d\n", test->url, url.nScheme, test->scheme);
226
227 if(test->host_off == -1)
228 ok(!url.lpszHostName, "[%s] url.lpszHostName = %p, expected NULL\n", test->url, url.lpszHostName);
229 else
230 ok(url.lpszHostName == test->url+test->host_off, "[%s] url.lpszHostName = %p, expected %p\n",
231 test->url, url.lpszHostName, test->url+test->host_off);
232 if(test->host_skip_broken != -1 && url.dwHostNameLength == test->host_skip_broken) {
233 win_skip("skipping broken dwHostNameLength result\n");
234 return;
235 }
236 ok(url.dwHostNameLength == test->host_len, "[%s] url.lpszHostNameLength = %ld, expected %d\n",
237 test->url, url.dwHostNameLength, test->host_len);
238
239 ok(url.nPort == test->port, "[%s] nPort = %d, expected %d\n", test->url, url.nPort, test->port);
240
241 if(test->user_off == -1)
242 ok(!url.lpszUserName, "[%s] url.lpszUserName = %p\n", test->url, url.lpszUserName);
243 else
244 ok(url.lpszUserName == test->url+test->user_off, "[%s] url.lpszUserName = %p, expected %p\n",
245 test->url, url.lpszUserName, test->url+test->user_off);
246 ok(url.dwUserNameLength == test->user_len, "[%s] url.lpszUserNameLength = %ld, expected %d\n",
247 test->url, url.dwUserNameLength, test->user_len);
248
249 if(test->pass_off == -1)
250 ok(!url.lpszPassword, "[%s] url.lpszPassword = %p\n", test->url, url.lpszPassword);
251 else
252 ok(url.lpszPassword == test->url+test->pass_off, "[%s] url.lpszPassword = %p, expected %p\n",
253 test->url, url.lpszPassword, test->url+test->pass_off);
254 ok(url.dwPasswordLength == test->pass_len, "[%s] url.lpszPasswordLength = %ld, expected %d\n",
255 test->url, url.dwPasswordLength, test->pass_len);
256
257 if(test->path_off == -1)
258 ok(!url.lpszUrlPath, "[%s] url.lpszUrlPath = %p, expected NULL\n", test->url, url.lpszUrlPath);
259 else
260 ok(url.lpszUrlPath == test->url+test->path_off, "[%s] url.lpszUrlPath = %p, expected %p\n",
261 test->url, url.lpszUrlPath, test->url+test->path_off);
262 ok(url.dwUrlPathLength == test->path_len, "[%s] url.lpszUrlPathLength = %ld, expected %d\n",
263 test->url, url.dwUrlPathLength, test->path_len);
264
265 if(test->extra_off == -1)
266 ok(!url.lpszExtraInfo, "[%s] url.lpszExtraInfo = %p, expected NULL\n", test->url, url.lpszExtraInfo);
267 else
268 ok(url.lpszExtraInfo == test->url+test->extra_off, "[%s] url.lpszExtraInfo = %p, expected %p\n",
269 test->url, url.lpszExtraInfo, test->url+test->extra_off);
270 ok(url.dwExtraInfoLength == test->extra_len, "[%s] url.lpszExtraInfoLength = %ld, expected %d\n",
271 test->url, url.dwExtraInfoLength, test->extra_len);
272
273 /* test InternetCrackUrlW with NULL buffers */
274 memset(&urlw, 0, sizeof(URL_COMPONENTSW));
275 urlw.dwStructSize = sizeof(URL_COMPONENTSW);
276 urlw.dwSchemeLength = 1;
277 urlw.dwHostNameLength = 1;
278 urlw.dwUserNameLength = 1;
279 urlw.dwPasswordLength = 1;
280 urlw.dwUrlPathLength = 1;
281 urlw.dwExtraInfoLength = 1;
282
283 buf = a2w(test->url);
284 b = InternetCrackUrlW(buf, lstrlenW(buf), 0, &urlw);
286 win_skip("InternetCrackUrlW is not implemented\n");
288 return;
289 }
290 ok(b, "InternetCrackUrl failed with error %ld\n", GetLastError());
291
292 if(test->scheme_off == -1)
293 ok(!urlw.lpszScheme, "[%s] urlw.lpszScheme = %p, expected NULL\n", test->url, urlw.lpszScheme);
294 else
295 ok(urlw.lpszScheme == buf+test->scheme_off, "[%s] urlw.lpszScheme = %p, expected %p\n",
296 test->url, urlw.lpszScheme, buf+test->scheme_off);
297 ok(urlw.dwSchemeLength == test->scheme_len, "[%s] urlw.lpszSchemeLength = %ld, expected %d\n",
298 test->url, urlw.dwSchemeLength, test->scheme_len);
299
300 ok(urlw.nScheme == test->scheme, "[%s] urlw.nScheme = %d, expected %d\n", test->url, urlw.nScheme, test->scheme);
301
302 if(test->host_off == -1) {
303 ok(!urlw.lpszHostName, "[%s] urlw.lpszHostName = %p, expected NULL\n", test->url, urlw.lpszHostName);
304 ok(urlw.dwHostNameLength == 0 || broken(urlw.dwHostNameLength == 1), "[%s] urlw.lpszHostNameLength = %ld, expected %d\n",
305 test->url, urlw.dwHostNameLength, test->host_len);
306 }else {
307 ok(urlw.lpszHostName == buf+test->host_off, "[%s] urlw.lpszHostName = %p, expected %p\n",
308 test->url, urlw.lpszHostName, test->url+test->host_off);
309 ok(urlw.dwHostNameLength == test->host_len, "[%s] urlw.lpszHostNameLength = %ld, expected %d\n",
310 test->url, urlw.dwHostNameLength, test->host_len);
311 }
312
313 ok(urlw.nPort == test->port, "[%s] nPort = %d, expected %d\n", test->url, urlw.nPort, test->port);
314
315 if(test->user_off == -1) {
316 ok(!urlw.lpszUserName, "[%s] urlw.lpszUserName = %p\n", test->url, urlw.lpszUserName);
317 ok(urlw.dwUserNameLength == 0 || broken(urlw.dwUserNameLength == 1), "[%s] urlw.lpszUserNameLength = %ld, expected %d\n",
318 test->url, urlw.dwUserNameLength, test->user_len);
319 }else {
320 ok(urlw.lpszUserName == buf+test->user_off, "[%s] urlw.lpszUserName = %p, expected %p\n",
321 test->url, urlw.lpszUserName, buf+test->user_off);
322 ok(urlw.dwUserNameLength == test->user_len, "[%s] urlw.lpszUserNameLength = %ld, expected %d\n",
323 test->url, urlw.dwUserNameLength, test->user_len);
324 }
325
326 if(test->pass_off == -1) {
327 ok(!urlw.lpszPassword, "[%s] urlw.lpszPassword = %p\n", test->url, urlw.lpszPassword);
328 ok(urlw.dwPasswordLength == 0 || broken(urlw.dwPasswordLength), "[%s] urlw.lpszPasswordLength = %ld, expected %d\n",
329 test->url, urlw.dwPasswordLength, test->pass_len);
330 }else {
331 ok(urlw.lpszPassword == buf+test->pass_off, "[%s] urlw.lpszPassword = %p, expected %p\n",
332 test->url, urlw.lpszPassword, buf+test->pass_off);
333 ok(urlw.dwPasswordLength == test->pass_len, "[%s] urlw.lpszPasswordLength = %ld, expected %d\n",
334 test->url, urlw.dwPasswordLength, test->pass_len);
335 }
336
337 if(test->path_off == -1)
338 ok(!urlw.lpszUrlPath, "[%s] urlw.lpszUrlPath = %p, expected NULL\n", test->url, urlw.lpszUrlPath);
339 else
340 ok(urlw.lpszUrlPath == buf+test->path_off, "[%s] urlw.lpszUrlPath = %p, expected %p\n",
341 test->url, urlw.lpszUrlPath, buf+test->path_off);
342 ok(urlw.dwUrlPathLength == test->path_len, "[%s] urlw.lpszUrlPathLength = %ld, expected %d\n",
343 test->url, urlw.dwUrlPathLength, test->path_len);
344
345 if(test->extra_off == -1) {
346 ok(!urlw.lpszExtraInfo, "[%s] url.lpszExtraInfo = %p, expected NULL\n", test->url, urlw.lpszExtraInfo);
347 ok(urlw.dwExtraInfoLength == 0 || broken(urlw.dwExtraInfoLength == 1), "[%s] urlw.lpszExtraInfoLength = %ld, expected %d\n",
348 test->url, urlw.dwExtraInfoLength, test->extra_len);
349 }else {
350 ok(urlw.lpszExtraInfo == buf+test->extra_off, "[%s] urlw.lpszExtraInfo = %p, expected %p\n",
351 test->url, urlw.lpszExtraInfo, buf+test->extra_off);
352 ok(urlw.dwExtraInfoLength == test->extra_len, "[%s] urlw.lpszExtraInfoLength = %ld, expected %d\n",
353 test->url, urlw.dwExtraInfoLength, test->extra_len);
354 }
355
356 /* test InternetCrackUrlA with valid buffers */
357 scheme_a = (char*)(scheme_w = HeapAlloc(GetProcessHeap(), 0, buf_len*sizeof(WCHAR)));
358 hostname_a = (char*)(hostname_w = HeapAlloc(GetProcessHeap(), 0, buf_len*sizeof(WCHAR)));
359 username_a = (char*)(username_w = HeapAlloc(GetProcessHeap(), 0, buf_len*sizeof(WCHAR)));
360 password_a = (char*)(password_w = HeapAlloc(GetProcessHeap(), 0, buf_len*sizeof(WCHAR)));
361 urlpath_a = (char*)(urlpath_w = HeapAlloc(GetProcessHeap(), 0, buf_len*sizeof(WCHAR)));
362 extrainfo_a = (char*)(extrainfo_w = HeapAlloc(GetProcessHeap(), 0, buf_len*sizeof(WCHAR)));
363 memset(&url, 0, sizeof(URL_COMPONENTSA));
364 url.dwStructSize = sizeof(URL_COMPONENTSA);
365 url.lpszScheme = scheme_a;
366 url.dwSchemeLength = buf_len;
367 url.lpszHostName = hostname_a;
368 url.dwHostNameLength = buf_len;
369 url.lpszUserName = username_a;
370 url.dwUserNameLength = buf_len;
371 url.lpszPassword = password_a;
372 url.dwPasswordLength = buf_len;
373 url.lpszUrlPath = urlpath_a;
374 url.dwUrlPathLength = buf_len;
375 url.lpszExtraInfo = extrainfo_a;
376 url.dwExtraInfoLength = buf_len;
377
378 b = InternetCrackUrlA(test->url, strlen(test->url), 0, &url);
379 ok(b, "InternetCrackUrlA failed with error %ld\n", GetLastError());
380
381 ok(url.dwSchemeLength == strlen(test->exp_scheme), "[%s] Got wrong scheme length: %ld\n",
382 test->url, url.dwSchemeLength);
383 ok(!strcmp(scheme_a, test->exp_scheme), "[%s] Got wrong scheme, expected: %s, got: %s\n",
384 test->url, test->exp_scheme, scheme_a);
385
386 ok(url.nScheme == test->scheme, "[%s] Got wrong nScheme, expected: %d, got: %d\n",
387 test->url, test->scheme, url.nScheme);
388
389 ok(url.dwHostNameLength == strlen(test->exp_hostname), "[%s] Got wrong hostname length: %ld\n",
390 test->url, url.dwHostNameLength);
391 ok(!strcmp(hostname_a, test->exp_hostname), "[%s] Got wrong hostname, expected: %s, got: %s\n",
392 test->url, test->exp_hostname, hostname_a);
393
394 ok(url.nPort == test->port, "[%s] Got wrong port, expected: %d, got: %d\n",
395 test->url, test->port, url.nPort);
396
397 ok(url.dwUserNameLength == strlen(test->exp_username), "[%s] Got wrong username length: %ld\n",
398 test->url, url.dwUserNameLength);
399 ok(!strcmp(username_a, test->exp_username), "[%s] Got wrong username, expected: %s, got: %s\n",
400 test->url, test->exp_username, username_a);
401
402 ok(url.dwPasswordLength == strlen(test->exp_password), "[%s] Got wrong password length: %ld\n",
403 test->url, url.dwPasswordLength);
404 ok(!strcmp(password_a, test->exp_password), "[%s] Got wrong password, expected: %s, got: %s\n",
405 test->url, test->exp_password, password_a);
406
407 ok(url.dwUrlPathLength == strlen(test->exp_urlpath), "[%s] Got wrong urlpath length: %ld\n",
408 test->url, url.dwUrlPathLength);
409 ok(!strcmp(urlpath_a, test->exp_urlpath), "[%s] Got wrong urlpath, expected: %s, got: %s\n",
410 test->url, test->exp_urlpath, urlpath_a);
411
412 ok(url.dwExtraInfoLength == strlen(test->exp_extrainfo), "[%s] Got wrong extrainfo length: %ld\n",
413 test->url, url.dwExtraInfoLength);
414 ok(!strcmp(extrainfo_a, test->exp_extrainfo), "[%s] Got wrong extrainfo, expected: %s, got: %s\n",
415 test->url, test->exp_extrainfo, extrainfo_a);
416
417 /* test InternetCrackUrlW with valid buffers */
418 memset(&urlw, 0, sizeof(URL_COMPONENTSW));
419 urlw.dwStructSize = sizeof(URL_COMPONENTSW);
420 urlw.lpszScheme = scheme_w;
421 urlw.dwSchemeLength = buf_len;
422 urlw.lpszHostName = hostname_w;
423 urlw.dwHostNameLength = buf_len;
424 urlw.lpszUserName = username_w;
425 urlw.dwUserNameLength = buf_len;
426 urlw.lpszPassword = password_w;
427 urlw.dwPasswordLength = buf_len;
428 urlw.lpszUrlPath = urlpath_w;
429 urlw.dwUrlPathLength = buf_len;
430 urlw.lpszExtraInfo = extrainfo_w;
431 urlw.dwExtraInfoLength = buf_len;
432
433 b = InternetCrackUrlW(buf, lstrlenW(buf), 0, &urlw);
434 ok(b, "InternetCrackUrlW failed with error %ld\n", GetLastError());
435
436 ok(urlw.dwSchemeLength == strlen(test->exp_scheme), "[%s] Got wrong scheme length: %ld\n",
437 test->url, urlw.dwSchemeLength);
438 ok(!strcmp_wa(scheme_w, test->exp_scheme), "[%s] Got wrong scheme, expected: %s, got: %s\n",
439 test->url, test->exp_scheme, wine_dbgstr_w(scheme_w));
440
441 ok(urlw.nScheme == test->scheme, "[%s] Got wrong nScheme, expected: %d, got: %d\n",
442 test->url, test->scheme, urlw.nScheme);
443
444 ok(urlw.dwHostNameLength == strlen(test->exp_hostname), "[%s] Got wrong hostname length: %ld\n",
445 test->url, urlw.dwHostNameLength);
446 ok(!strcmp_wa(hostname_w, test->exp_hostname), "[%s] Got wrong hostname, expected: %s, got: %s\n",
447 test->url, test->exp_hostname, wine_dbgstr_w(hostname_w));
448
449 ok(urlw.nPort == test->port, "[%s] Got wrong port, expected: %d, got: %d\n",
450 test->url, test->port, urlw.nPort);
451
452 ok(urlw.dwUserNameLength == strlen(test->exp_username), "[%s] Got wrong username length: %ld\n",
453 test->url, urlw.dwUserNameLength);
454 ok(!strcmp_wa(username_w, test->exp_username), "[%s] Got wrong username, expected: %s, got: %s\n",
455 test->url, test->exp_username, wine_dbgstr_w(username_w));
456
457 ok(urlw.dwPasswordLength == strlen(test->exp_password), "[%s] Got wrong password length: %ld\n",
458 test->url, urlw.dwPasswordLength);
459 ok(!strcmp_wa(password_w, test->exp_password), "[%s] Got wrong password, expected: %s, got: %s\n",
460 test->url, test->exp_password, wine_dbgstr_w(password_w));
461
462 ok(urlw.dwUrlPathLength == strlen(test->exp_urlpath), "[%s] Got wrong urlpath length: %ld\n",
463 test->url, urlw.dwUrlPathLength);
464 ok(!strcmp_wa(urlpath_w, test->exp_urlpath), "[%s] Got wrong urlpath, expected: %s, got: %s\n",
465 test->url, test->exp_urlpath, wine_dbgstr_w(urlpath_w));
466
467 ok(urlw.dwExtraInfoLength == strlen(test->exp_extrainfo), "[%s] Got wrong extrainfo length: %ld\n",
468 test->url, urlw.dwExtraInfoLength);
469 ok(!strcmp_wa(extrainfo_w, test->exp_extrainfo), "[%s] Got wrong extrainfo, expected: %s, got: %s\n",
470 test->url, test->exp_extrainfo, wine_dbgstr_w(extrainfo_w));
471
472 HeapFree(GetProcessHeap(), 0, scheme_w);
473 HeapFree(GetProcessHeap(), 0, hostname_w);
474 HeapFree(GetProcessHeap(), 0, username_w);
475 HeapFree(GetProcessHeap(), 0, password_w);
476 HeapFree(GetProcessHeap(), 0, urlpath_w);
477 HeapFree(GetProcessHeap(), 0, extrainfo_w);
479}
#define lstrlenW
Definition: compat.h:750
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define b
Definition: ke_i.h:79
static void zero_compsA(URL_COMPONENTSA *dst, DWORD scheLen, DWORD hostLen, DWORD userLen, DWORD passLen, DWORD pathLen, DWORD extrLen)
Definition: url.c:72
#define test
Definition: rosglue.h:37
INTERNET_SCHEME nScheme
Definition: wininet.h:214
INTERNET_PORT nPort
Definition: wininet.h:217

Referenced by START_TEST(), and test_long_url().

◆ test_long_url()

static void test_long_url ( void  )
static

Definition at line 481 of file url.c.

482{
483 char long_buf[6000];
484 char long_url[sizeof(long_buf) + 1000];
485 crack_url_test_t test_long_path =
486 {long_url, 0, 4, INTERNET_SCHEME_HTTP, 7, 14, -1, 80, -1, 0, -1, 0, 21, sizeof(long_buf)-1, -1, 0,
487 "http", "www.winehq.org", "", "", long_buf, ""};
488 crack_url_test_t test_long_extra =
489 {long_url, 0, 4, INTERNET_SCHEME_HTTP, 7, 14, -1, 80, -1, 0, -1, 0, 21, 6, 27, sizeof(long_buf)-1,
490 "http", "www.winehq.org", "", "", "/path/", long_buf};
491 URL_COMPONENTSA url_comp;
492 BOOL b;
493
494 memset(long_buf, 'x', sizeof(long_buf));
495 long_buf[0] = '/';
496 long_buf[sizeof(long_buf)-1] = 0;
497
498 strcpy(long_url, "http://www.winehq.org");
499 strcat(long_url, long_buf);
500 test_crack_url(&test_long_path);
501
502 strcpy(long_url, "http://www.winehq.org/path/");
503 long_buf[0] = '#';
504 strcat(long_url, long_buf);
505 test_crack_url(&test_long_extra);
506
507 zero_compsA(&url_comp, 0, 0, 0, 0, 0, 100);
508 url_comp.lpszExtraInfo = long_buf;
509 b = InternetCrackUrlA(long_url, strlen(long_url), 0, &url_comp);
510 ok(!b && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "InternetCrackUrlA returned %x with error %ld\n", b, GetLastError());
511
512 zero_compsA(&url_comp, 4, 0, 0, 0, 0, 0);
513 url_comp.lpszScheme = long_buf;
514 b = InternetCrackUrlA(long_url, strlen(long_url), 0, &url_comp);
515 ok(!b && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "InternetCrackUrlA returned %x with error %ld\n", b, GetLastError());
516}
strcat
Definition: string.h:92
strcpy
Definition: string.h:131

Referenced by START_TEST(), and test_http_connection().

◆ zero_compsA()

static void zero_compsA ( URL_COMPONENTSA *  dst,
DWORD  scheLen,
DWORD  hostLen,
DWORD  userLen,
DWORD  passLen,
DWORD  pathLen,
DWORD  extrLen 
)
static

Definition at line 72 of file url.c.

80{
82 dst->dwStructSize = sizeof(URL_COMPONENTSA);
83 dst->dwSchemeLength = scheLen;
84 dst->dwHostNameLength = hostLen;
85 dst->dwUserNameLength = userLen;
86 dst->dwPasswordLength = passLen;
87 dst->dwUrlPathLength = pathLen;
88 dst->dwExtraInfoLength = extrLen;
89 SetLastError(0xfaceabad);
90}

Referenced by test_crack_url(), and test_long_url().

Variable Documentation

◆ crack_url_tests

const crack_url_test_t crack_url_tests[]
static

Definition at line 117 of file url.c.

Referenced by START_TEST().