ReactOS 0.4.15-dev-7934-g1dc8d80
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 WCHARa2w (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
GLenum GLsizei len
Definition: glext.h:6722
const WCHAR * str
int ret
__wchar_t WCHAR
Definition: xmlstorage.h:180

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 830 of file url.c.

831{
832 static CHAR http[] = "http",
833 winehq[] = "www.winehq.org",
834 username[] = "username",
835 password[] = "password",
836 site_about[] = "/site/about",
837 empty[] = "";
838
839 lpUrlComponents->dwStructSize = sizeof(URL_COMPONENTSA);
840 lpUrlComponents->lpszScheme = http;
841 lpUrlComponents->dwSchemeLength = strlen(lpUrlComponents->lpszScheme);
842 lpUrlComponents->nScheme = INTERNET_SCHEME_HTTP;
843 lpUrlComponents->lpszHostName = winehq;
844 lpUrlComponents->dwHostNameLength = strlen(lpUrlComponents->lpszHostName);
845 lpUrlComponents->nPort = 80;
846 lpUrlComponents->lpszUserName = username;
847 lpUrlComponents->dwUserNameLength = strlen(lpUrlComponents->lpszUserName);
848 lpUrlComponents->lpszPassword = password;
849 lpUrlComponents->dwPasswordLength = strlen(lpUrlComponents->lpszPassword);
850 lpUrlComponents->lpszUrlPath = site_about;
851 lpUrlComponents->dwUrlPathLength = strlen(lpUrlComponents->lpszUrlPath);
852 lpUrlComponents->lpszExtraInfo = empty;
853 lpUrlComponents->dwExtraInfoLength = strlen(lpUrlComponents->lpszExtraInfo);
854}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static WCHAR empty[]
Definition: url.c:28
static WCHAR http[]
Definition: url.c:30
static WCHAR winehq[]
Definition: url.c:31
static WCHAR password[]
Definition: url.c:33
static WCHAR username[]
Definition: url.c:32
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:42
char CHAR
Definition: xmlstorage.h:175

◆ InternetCanonicalizeUrl_test()

static void InternetCanonicalizeUrl_test ( void  )
static

Definition at line 1183 of file url.c.

1184{
1185 char src[] = "http://www.winehq.org/%27/ /./>/#> ";
1186 char dst[64];
1187 DWORD dstlen;
1188
1189 dstlen = sizeof(dst);
1191 ok(strcmp(dst, "http://www.winehq.org/%27/%20/%3E/#>") == 0, "Got \"%s\"\n", dst);
1192
1193 /* despite what MSDN says, ICU_BROWSER_MODE seems to be ignored */
1194 dstlen = sizeof(dst);
1196 ok(strcmp(dst, "http://www.winehq.org/%27/%20/%3E/#>") == 0, "Got \"%s\"\n", dst);
1197
1198 /* ICU_ESCAPE is supposed to be ignored */
1199 dstlen = sizeof(dst);
1201 ok(strcmp(dst, "http://www.winehq.org/%27/%20/%3E/#>") == 0, "Got \"%s\"\n", dst);
1202
1203 dstlen = sizeof(dst);
1205 ok(strcmp(dst, "http://www.winehq.org/'/%20/%3E/#>") == 0, "Got \"%s\"\n", dst);
1206
1207 dstlen = sizeof(dst);
1209 ok(strcmp(dst, "http://www.winehq.org/%2527/%20/%3E/#>") == 0, "Got \"%s\"\n", dst);
1210
1211 dstlen = sizeof(dst);
1213 ok(strcmp(dst, "http://www.winehq.org/%27/%20/>/#>") == 0, "Got \"%s\"\n", dst);
1214
1215 dstlen = sizeof(dst);
1217 ok(strcmp(dst, "http://www.winehq.org/%27/ />/#>") == 0, "Got \"%s\"\n", dst);
1218
1219 dstlen = sizeof(dst);
1221 ok(strcmp(dst, "http://www.winehq.org/%27/%20/./%3E/#>") == 0, "Got \"%s\"\n", dst);
1222}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI InternetCanonicalizeUrlA(LPCSTR lpszUrl, LPSTR lpszBuffer, LPDWORD lpdwBufferLength, DWORD dwFlags)
Definition: internet.c:1978
unsigned long DWORD
Definition: ntddk_ex.h:95
static DWORD dstlen
Definition: directory.c:51
#define ICU_NO_META
Definition: winhttp.h:292
#define ICU_ENCODE_SPACES_ONLY
Definition: winhttp.h:293
#define ICU_DECODE
Definition: winhttp.h:291
#define ICU_BROWSER_MODE
Definition: winhttp.h:294
#define ICU_NO_ENCODE
Definition: winhttp.h:290
#define ICU_ESCAPE
Definition: winhttp.h:48
#define ICU_ENCODE_PERCENT
Definition: winhttp.h:295

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=%d (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=%d (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=%d (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=%d (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=%d (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=%d (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 %d\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 %d\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}
#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:1506
unsigned int BOOL
Definition: ntddk_ex.h:94
@ extra
Definition: id3.c:95
static DWORD GLE
Definition: registry.c:38
#define todo_wine
Definition: custom.c:79
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
#define ZeroMemory
Definition: winbase.h:1712
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_INTERNET_UNRECOGNIZED_SCHEME
Definition: wininet.h:1995
static const WCHAR userName[]
Definition: wnet.c:2154

Referenced by START_TEST().

◆ InternetCrackUrlW_test()

static void InternetCrackUrlW_test ( void  )
static

Definition at line 658 of file url.c.

659{
660 WCHAR url[] = {
661 'h','t','t','p',':','/','/','1','9','2','.','1','6','8','.','0','.','2','2','/',
662 'C','F','I','D','E','/','m','a','i','n','.','c','f','m','?','C','F','S','V','R',
663 '=','I','D','E','&','A','C','T','I','O','N','=','I','D','E','_','D','E','F','A',
664 'U','L','T', 0 };
665 static const WCHAR url2[] = { '.','.','/','R','i','t','z','.','x','m','l',0 };
666 static const WCHAR url3[] = { 'h','t','t','p',':','/','/','x','.','o','r','g',0 };
667 URL_COMPONENTSW comp;
668 WCHAR scheme[20], host[20], user[20], pwd[20], urlpart[50], extra[50];
669 DWORD error;
670 BOOL r;
671
672 urlpart[0]=0;
673 scheme[0]=0;
674 extra[0]=0;
675 host[0]=0;
676 user[0]=0;
677 pwd[0]=0;
678 memset(&comp, 0, sizeof comp);
679 comp.dwStructSize = sizeof(comp);
680 comp.lpszScheme = scheme;
682 comp.lpszHostName = host;
684 comp.lpszUserName = user;
686 comp.lpszPassword = pwd;
688 comp.lpszUrlPath = urlpart;
689 comp.dwUrlPathLength = ARRAY_SIZE(urlpart);
690 comp.lpszExtraInfo = extra;
692
693 SetLastError(0xdeadbeef);
694 r = InternetCrackUrlW(NULL, 0, 0, &comp );
697 {
698 win_skip("InternetCrackUrlW is not implemented\n");
699 return;
700 }
701 ok( !r, "InternetCrackUrlW succeeded unexpectedly\n");
704 "expected ERROR_INVALID_PARAMETER got %u\n", error);
705
707 {
708 /* Crashes on IE5 */
709 SetLastError(0xdeadbeef);
710 r = InternetCrackUrlW(url, 0, 0, NULL );
712 ok( !r, "InternetCrackUrlW succeeded unexpectedly\n");
713 ok( error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", error);
714 }
715
716 r = InternetCrackUrlW(url, 0, 0, &comp );
717 ok( r, "failed to crack url\n");
718 ok( comp.dwSchemeLength == 4, "scheme length wrong\n");
719 ok( comp.dwHostNameLength == 12, "host length wrong\n");
720 ok( comp.dwUserNameLength == 0, "user length wrong\n");
721 ok( comp.dwPasswordLength == 0, "password length wrong\n");
722 ok( comp.dwUrlPathLength == 15, "url length wrong\n");
723 ok( comp.dwExtraInfoLength == 29, "extra length wrong\n");
724
725 urlpart[0]=0;
726 host[0]=0;
727 memset(&comp, 0, sizeof comp);
728 comp.dwStructSize = sizeof comp;
729 comp.lpszHostName = host;
731 comp.lpszUrlPath = urlpart;
732 comp.dwUrlPathLength = ARRAY_SIZE(urlpart);
733
734 r = InternetCrackUrlW(url, 0, 0, &comp );
735 ok( r, "failed to crack url\n");
736 ok( comp.dwSchemeLength == 0, "scheme length wrong\n");
737 ok( comp.dwHostNameLength == 12, "host length wrong\n");
738 ok( comp.dwUserNameLength == 0, "user length wrong\n");
739 ok( comp.dwPasswordLength == 0, "password length wrong\n");
740 ok( comp.dwUrlPathLength == 44, "url length wrong\n");
741 ok( comp.dwExtraInfoLength == 0, "extra length wrong\n");
742
743 urlpart[0]=0;
744 host[0]=0;
745 memset(&comp, 0, sizeof comp);
746 comp.dwStructSize = sizeof comp;
747 comp.lpszHostName = host;
749 comp.lpszUrlPath = urlpart;
750 comp.dwUrlPathLength = ARRAY_SIZE(urlpart);
751 comp.lpszExtraInfo = NULL;
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 == 15, "url length wrong\n");
761 ok( comp.dwExtraInfoLength == 29, "extra length wrong\n");
762
763 urlpart[0]=0;
764 scheme[0]=0;
765 extra[0]=0;
766 host[0]=0;
767 user[0]=0;
768 pwd[0]=0;
769 memset(&comp, 0, sizeof(comp));
770 comp.dwStructSize = sizeof(comp);
771 comp.lpszScheme = scheme;
773 comp.lpszHostName = host;
775 comp.lpszUserName = user;
777 comp.lpszPassword = pwd;
779 comp.lpszUrlPath = urlpart;
780 comp.dwUrlPathLength = ARRAY_SIZE(urlpart);
781 comp.lpszExtraInfo = extra;
783
784 r = InternetCrackUrlW(url2, 0, 0, &comp);
785 ok(!r, "InternetCrackUrl should have failed\n");
787 "InternetCrackUrl should have failed with error ERROR_INTERNET_UNRECOGNIZED_SCHEME instead of error %d\n",
788 GetLastError());
789
790 /* Test to see whether cracking a URL without a filename initializes urlpart */
791 urlpart[0]=0xba;
792 scheme[0]=0;
793 extra[0]=0;
794 host[0]=0;
795 user[0]=0;
796 pwd[0]=0;
797 memset(&comp, 0, sizeof comp);
798 comp.dwStructSize = sizeof comp;
799 comp.lpszScheme = scheme;
801 comp.lpszHostName = host;
803 comp.lpszUserName = user;
805 comp.lpszPassword = pwd;
807 comp.lpszUrlPath = urlpart;
808 comp.dwUrlPathLength = ARRAY_SIZE(urlpart);
809 comp.lpszExtraInfo = extra;
811 r = InternetCrackUrlW(url3, 0, 0, &comp );
812 ok( r, "InternetCrackUrlW failed unexpectedly\n");
813 ok( host[0] == 'x', "host should be x.org\n");
814 ok( urlpart[0] == 0, "urlpart should be empty\n");
815
816 urlpart[0] = 0;
817 host[0] = 0;
818 memset(&comp, 0, sizeof(comp));
819 comp.dwStructSize = sizeof(comp);
820 comp.lpszHostName = host;
822 comp.lpszUrlPath = urlpart;
823 comp.dwUrlPathLength = ARRAY_SIZE(urlpart);
824 r = InternetCrackUrlW(url3, 0, ICU_DECODE, &comp);
825 ok(r, "InternetCrackUrlW failed unexpectedly\n");
826 ok(!strcmp_wa(host, "x.org"), "host is %s, should be x.org\n", wine_dbgstr_w(host));
827 todo_wine ok(urlpart[0] == 0, "urlpart should be empty\n");
828}
#define broken(x)
Definition: _sntprintf.h:21
void pwd(int argc, const char *argv[])
Definition: cmds.c:1401
void user(int argc, const char *argv[])
Definition: cmds.c:1350
#define ARRAY_SIZE(A)
Definition: main.h:33
#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:1625
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define wine_dbgstr_w
Definition: kernel32.h:34
#define error(str)
Definition: mkdosfs.c:1605
static const WCHAR url[]
Definition: encode.c:1432
static const WCHAR url2[]
Definition: misc.c:302
static const WCHAR url3[]
Definition: url.c:45
static int strcmp_wa(const WCHAR *str1, const char *str2)
Definition: url.c:191
DWORD scheme
#define win_skip
Definition: test.h:160
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
char * host
Definition: whois.c:55

Referenced by START_TEST().

◆ InternetCreateUrlA_test()

static void InternetCreateUrlA_test ( void  )
static

Definition at line 856 of file url.c.

857{
858 URL_COMPONENTSA urlComp;
859 LPSTR szUrl;
860 DWORD len = -1;
861 BOOL ret;
862 static CHAR empty[] = "",
863 nhttp[] = "nhttp",
864 http[] = "http",
865 https[] = "https",
866 winehq[] = "www.winehq.org",
867 localhost[] = "localhost",
868 username[] = "username",
869 password[] = "password",
870 root[] = "/",
871 site_about[] = "/site/about",
872 extra_info[] = "?test=123",
873 about[] = "about",
874 blank[] = "blank",
875 host[] = "host";
876
877 /* test NULL lpUrlComponents */
878 SetLastError(0xdeadbeef);
880 ok(!ret, "Expected failure\n");
882 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
883 ok(len == -1, "Expected len -1, got %d\n", len);
884
885 /* test zero'ed lpUrlComponents */
886 ZeroMemory(&urlComp, sizeof(urlComp));
887 SetLastError(0xdeadbeef);
888 ret = InternetCreateUrlA(&urlComp, 0, NULL, &len);
889 ok(!ret, "Expected failure\n");
891 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
892 ok(len == -1, "Expected len -1, got %d\n", len);
893
894 /* test valid lpUrlComponents, NULL lpdwUrlLength */
895 fill_url_components(&urlComp);
896 SetLastError(0xdeadbeef);
897 ret = InternetCreateUrlA(&urlComp, 0, NULL, NULL);
898 ok(!ret, "Expected failure\n");
900 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
901
902 /* test valid lpUrlComponents, empty szUrl
903 * lpdwUrlLength is size of buffer required on exit, including
904 * the terminating null when GLE == ERROR_INSUFFICIENT_BUFFER
905 */
906 SetLastError(0xdeadbeef);
907 ret = InternetCreateUrlA(&urlComp, 0, NULL, &len);
908 ok(!ret, "Expected failure\n");
910 "Expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
911 ok(len == 51, "Expected len 51, got %d\n", len);
912
913 /* test correct size, NULL szUrl */
914 fill_url_components(&urlComp);
915 SetLastError(0xdeadbeef);
916 ret = InternetCreateUrlA(&urlComp, 0, NULL, &len);
917 ok(!ret, "Expected failure\n");
919 "Expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
920 ok(len == 51, "Expected len 51, got %d\n", len);
921
922 /* test valid lpUrlComponents, alloc-ed szUrl, small size */
923 SetLastError(0xdeadbeef);
924 szUrl = HeapAlloc(GetProcessHeap(), 0, len);
925 len -= 2;
926 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
927 ok(!ret, "Expected failure\n");
929 "Expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
930 ok(len == 51, "Expected len 51, got %d\n", len);
931
932 /* alloc-ed szUrl, NULL lpszScheme
933 * shows that it uses nScheme instead
934 */
935 urlComp.lpszScheme = NULL;
936 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
937 ok(ret, "Expected success\n");
938 ok(len == 50, "Expected len 50, got %d\n", len);
939 ok(!strcmp(szUrl, CREATE_URL1), "Expected %s, got %s\n", CREATE_URL1, szUrl);
940
941 /* alloc-ed szUrl, invalid nScheme
942 * any nScheme out of range seems ignored
943 */
944 fill_url_components(&urlComp);
945 urlComp.nScheme = -3;
946 len++;
947 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
948 ok(ret, "Expected success\n");
949 ok(len == 50, "Expected len 50, got %d\n", len);
950
951 /* test valid lpUrlComponents, alloc-ed szUrl */
952 fill_url_components(&urlComp);
953 len = 51;
954 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
955 ok(ret, "Expected success\n");
956 ok(len == 50, "Expected len 50, got %d\n", len);
957 ok(strstr(szUrl, "80") == NULL, "Didn't expect to find 80 in szUrl\n");
958 ok(!strcmp(szUrl, CREATE_URL1), "Expected %s, got %s\n", CREATE_URL1, szUrl);
959
960 /* valid username, NULL password */
961 fill_url_components(&urlComp);
962 urlComp.lpszPassword = NULL;
963 len = 42;
964 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
965 ok(ret, "Expected success\n");
966 ok(len == 41, "Expected len 41, got %d\n", len);
967 ok(!strcmp(szUrl, CREATE_URL2), "Expected %s, got %s\n", CREATE_URL2, szUrl);
968
969 /* valid username, empty password */
970 fill_url_components(&urlComp);
971 urlComp.lpszPassword = empty;
972 len = 51;
973 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
974 ok(ret, "Expected success\n");
975 ok(len == 50, "Expected len 50, got %d\n", len);
976 ok(!strcmp(szUrl, CREATE_URL3), "Expected %s, got %s\n", CREATE_URL3, szUrl);
977
978 /* valid password, NULL username
979 * if password is provided, username has to exist
980 */
981 fill_url_components(&urlComp);
982 SetLastError(0xdeadbeef);
983 urlComp.lpszUserName = NULL;
984 len = 42;
985 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
986 ok(!ret, "Expected failure\n");
988 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
989 ok(len == 42, "Expected len 42, got %d\n", len);
990 ok(!strcmp(szUrl, CREATE_URL3), "Expected %s, got %s\n", CREATE_URL3, szUrl);
991
992 /* valid password, empty username
993 * if password is provided, username has to exist
994 */
995 fill_url_components(&urlComp);
996 urlComp.lpszUserName = empty;
997 len = 51;
998 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
999 ok(ret, "Expected success\n");
1000 ok(len == 50, "Expected len 50, got %d\n", len);
1001 ok(!strcmp(szUrl, CREATE_URL5), "Expected %s, got %s\n", CREATE_URL5, szUrl);
1002
1003 /* NULL username, NULL password */
1004 fill_url_components(&urlComp);
1005 urlComp.lpszUserName = NULL;
1006 urlComp.lpszPassword = NULL;
1007 len = 42;
1008 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
1009 ok(ret, "Expected success\n");
1010 ok(len == 32, "Expected len 32, got %d\n", len);
1011 ok(!strcmp(szUrl, CREATE_URL4), "Expected %s, got %s\n", CREATE_URL4, szUrl);
1012
1013 /* empty username, empty password */
1014 fill_url_components(&urlComp);
1015 urlComp.lpszUserName = empty;
1016 urlComp.lpszPassword = empty;
1017 len = 51;
1018 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
1019 ok(ret, "Expected success\n");
1020 ok(len == 50, "Expected len 50, got %d\n", len);
1021 ok(!strcmp(szUrl, CREATE_URL5), "Expected %s, got %s\n", CREATE_URL5, szUrl);
1022
1023 /* shows that nScheme is ignored, as the appearance of the port number
1024 * depends on lpszScheme and the string copied depends on lpszScheme.
1025 */
1026 fill_url_components(&urlComp);
1027 HeapFree(GetProcessHeap(), 0, szUrl);
1028 urlComp.lpszScheme = nhttp;
1029 urlComp.dwSchemeLength = strlen(urlComp.lpszScheme);
1030 len = strlen(CREATE_URL6) + 1;
1031 szUrl = HeapAlloc(GetProcessHeap(), 0, len);
1032 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1033 ok(ret, "Expected success\n");
1034 ok(len == strlen(CREATE_URL6), "Expected len %d, got %d\n", lstrlenA(CREATE_URL6) + 1, len);
1035 ok(!strcmp(szUrl, CREATE_URL6), "Expected %s, got %s\n", CREATE_URL6, szUrl);
1036
1037 /* if lpszScheme != "http" or nPort != 80, display nPort */
1038 HeapFree(GetProcessHeap(), 0, szUrl);
1039 urlComp.lpszScheme = http;
1040 urlComp.dwSchemeLength = strlen(urlComp.lpszScheme);
1041 urlComp.nPort = 42;
1042 szUrl = HeapAlloc(GetProcessHeap(), 0, ++len);
1043 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1044 ok(ret, "Expected success\n");
1045 ok(len == 53, "Expected len 53, got %d\n", len);
1046 ok(strstr(szUrl, "42") != NULL, "Expected to find 42 in szUrl\n");
1047 ok(!strcmp(szUrl, CREATE_URL7), "Expected %s, got %s\n", CREATE_URL7, szUrl);
1048
1049 HeapFree(GetProcessHeap(), 0, szUrl);
1050
1051 memset(&urlComp, 0, sizeof(urlComp));
1052 urlComp.dwStructSize = sizeof(urlComp);
1053 urlComp.lpszScheme = http;
1054 urlComp.dwSchemeLength = 0;
1055 urlComp.nScheme = INTERNET_SCHEME_HTTP;
1056 urlComp.lpszHostName = winehq;
1057 urlComp.dwHostNameLength = 0;
1058 urlComp.nPort = 80;
1059 urlComp.lpszUserName = username;
1060 urlComp.dwUserNameLength = 0;
1061 urlComp.lpszPassword = password;
1062 urlComp.dwPasswordLength = 0;
1063 urlComp.lpszUrlPath = site_about;
1064 urlComp.dwUrlPathLength = 0;
1065 urlComp.lpszExtraInfo = empty;
1066 urlComp.dwExtraInfoLength = 0;
1068 szUrl = HeapAlloc(GetProcessHeap(), 0, ++len);
1069 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1070 ok(ret, "Expected success\n");
1071 ok(len == strlen(CREATE_URL1), "Expected len %d, got %d\n", lstrlenA(CREATE_URL1), len);
1072 ok(!strcmp(szUrl, CREATE_URL1), "Expected %s, got %s\n", CREATE_URL1, szUrl);
1073
1074 HeapFree(GetProcessHeap(), 0, szUrl);
1075
1076 memset(&urlComp, 0, sizeof(urlComp));
1077 urlComp.dwStructSize = sizeof(urlComp);
1078 urlComp.lpszScheme = https;
1079 urlComp.dwSchemeLength = 0;
1080 urlComp.nScheme = INTERNET_SCHEME_HTTP;
1081 urlComp.lpszHostName = winehq;
1082 urlComp.dwHostNameLength = 0;
1083 urlComp.nPort = 443;
1084 urlComp.lpszUserName = username;
1085 urlComp.dwUserNameLength = 0;
1086 urlComp.lpszPassword = password;
1087 urlComp.dwPasswordLength = 0;
1088 urlComp.lpszUrlPath = site_about;
1089 urlComp.dwUrlPathLength = 0;
1090 urlComp.lpszExtraInfo = empty;
1091 urlComp.dwExtraInfoLength = 0;
1093 szUrl = HeapAlloc(GetProcessHeap(), 0, ++len);
1094 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1095 ok(ret, "Expected success\n");
1096 ok(len == strlen(CREATE_URL8), "Expected len %d, got %d\n", lstrlenA(CREATE_URL8), len);
1097 ok(!strcmp(szUrl, CREATE_URL8), "Expected %s, got %s\n", CREATE_URL8, szUrl);
1098
1099 HeapFree(GetProcessHeap(), 0, szUrl);
1100
1101 memset(&urlComp, 0, sizeof(urlComp));
1102 urlComp.dwStructSize = sizeof(urlComp);
1103 urlComp.lpszScheme = about;
1104 urlComp.dwSchemeLength = 5;
1105 urlComp.lpszUrlPath = blank;
1106 urlComp.dwUrlPathLength = 5;
1108 len++; /* work around bug in native wininet */
1109 szUrl = HeapAlloc(GetProcessHeap(), 0, ++len);
1110 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1111 ok(ret, "Expected success\n");
1112 ok(len == strlen(CREATE_URL9), "Expected len %d, got %d\n", lstrlenA(CREATE_URL9), len);
1113 ok(!strcmp(szUrl, CREATE_URL9), "Expected %s, got %s\n", CREATE_URL9, szUrl);
1114
1115 HeapFree(GetProcessHeap(), 0, szUrl);
1116
1117 memset(&urlComp, 0, sizeof(urlComp));
1118 urlComp.dwStructSize = sizeof(urlComp);
1119 urlComp.lpszScheme = about;
1120 urlComp.lpszHostName = host;
1121 urlComp.lpszUrlPath = blank;
1123 len++; /* work around bug in native wininet */
1124 szUrl = HeapAlloc(GetProcessHeap(), 0, ++len);
1125 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1126 ok(ret, "Expected success\n");
1127 ok(len == strlen(CREATE_URL10), "Expected len %d, got %d\n", lstrlenA(CREATE_URL10), len);
1128 ok(!strcmp(szUrl, CREATE_URL10), "Expected %s, got %s\n", CREATE_URL10, szUrl);
1129
1130 HeapFree(GetProcessHeap(), 0, szUrl);
1131
1132 memset(&urlComp, 0, sizeof(urlComp));
1133 urlComp.dwStructSize = sizeof(urlComp);
1134 urlComp.nPort = 8080;
1135 urlComp.lpszScheme = about;
1137 szUrl = HeapAlloc(GetProcessHeap(), 0, ++len);
1138 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1139 ok(ret, "Expected success\n");
1140 ok(len == strlen(CREATE_URL11), "Expected len %d, got %d\n", lstrlenA(CREATE_URL11), len);
1141 ok(!strcmp(szUrl, CREATE_URL11), "Expected %s, got %s\n", CREATE_URL11, szUrl);
1142
1143 HeapFree(GetProcessHeap(), 0, szUrl);
1144
1145 memset(&urlComp, 0, sizeof(urlComp));
1146 urlComp.dwStructSize = sizeof(urlComp);
1147 urlComp.lpszScheme = http;
1148 urlComp.dwSchemeLength = 0;
1149 urlComp.nScheme = INTERNET_SCHEME_HTTP;
1150 urlComp.lpszHostName = winehq;
1151 urlComp.dwHostNameLength = 0;
1152 urlComp.nPort = 65535;
1154 szUrl = HeapAlloc(GetProcessHeap(), 0, ++len);
1155 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1156 ok(ret, "Expected success\n");
1157 ok(len == strlen(CREATE_URL12), "Expected len %d, got %d\n", lstrlenA(CREATE_URL12), len);
1158 ok(!strcmp(szUrl, CREATE_URL12), "Expected %s, got %s\n", CREATE_URL12, szUrl);
1159
1160 HeapFree(GetProcessHeap(), 0, szUrl);
1161
1162 memset(&urlComp, 0, sizeof(urlComp));
1163 urlComp.dwStructSize = sizeof(urlComp);
1164 urlComp.lpszScheme = http;
1165 urlComp.dwSchemeLength = strlen(urlComp.lpszScheme);
1166 urlComp.lpszHostName = localhost;
1167 urlComp.dwHostNameLength = strlen(urlComp.lpszHostName);
1168 urlComp.nPort = 80;
1169 urlComp.lpszUrlPath = root;
1170 urlComp.dwUrlPathLength = strlen(urlComp.lpszUrlPath);
1171 urlComp.lpszExtraInfo = extra_info;
1172 urlComp.dwExtraInfoLength = strlen(urlComp.lpszExtraInfo);
1173 len = 256;
1174 szUrl = HeapAlloc(GetProcessHeap(), 0, len);
1175 InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1176 ok(ret, "Expected success\n");
1177 ok(len == strlen(CREATE_URL13), "Got len %u\n", len);
1178 ok(!strcmp(szUrl, CREATE_URL13), "Expected \"%s\", got \"%s\"\n", CREATE_URL13, szUrl);
1179
1180 HeapFree(GetProcessHeap(), 0, szUrl);
1181}
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
struct _root root
#define HeapFree(x, y, z)
Definition: compat.h:735
BOOL WINAPI InternetCreateUrlA(LPURL_COMPONENTSA lpUrlComponents, DWORD dwFlags, LPSTR lpszUrl, LPDWORD lpdwUrlLength)
Definition: internet.c:4361
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
static const BYTE localhost[]
Definition: encode.c:1442
static void fill_url_components(URL_COMPONENTS *uc)
Definition: url.c:111
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: xmlstorage.h:182

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( url  )

Definition at line 1224 of file url.c.

1225{
1226 int i;
1227
1228 if(!GetProcAddress(GetModuleHandleA("wininet.dll"), "InternetGetCookieExW")) {
1229 win_skip("Too old IE (older than 6.0)\n");
1230 return;
1231 }
1232
1233 for(i = 0; i < ARRAY_SIZE(crack_url_tests); i++)
1235
1236 test_long_url();
1237
1242}
#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:658
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:856
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:1183

◆ 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 lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
static WCHAR * a2w(const char *str)
Definition: url.c:180

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 %d\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 = %d, 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 = %d, 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 = %d, 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 = %d, 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 = %d, 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 = %d, 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 %d\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 = %d, 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 = %d, 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 = %d, 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 = %d, 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 = %d, 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 = %d, 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 = %d, 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 = %d, 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 = %d, 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 = %d, 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 %d\n", GetLastError());
380
381 ok(url.dwSchemeLength == strlen(test->exp_scheme), "[%s] Got wrong scheme length: %d\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: %d\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: %d\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: %d\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: %d\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: %d\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 %d\n", GetLastError());
435
436 ok(urlw.dwSchemeLength == strlen(test->exp_scheme), "[%s] Got wrong scheme length: %d\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: %d\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: %d\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: %d\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: %d\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: %d\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 %d\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 %d\n", b, GetLastError());
516}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

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().