*/
#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+//#include <stdio.h>
+//#include <stdlib.h>
+//#include <string.h>
-#include "windef.h"
-#include "winbase.h"
-#include "winnls.h"
-#include "wininet.h"
+#include <windef.h>
+#include <winbase.h>
+#include <winnls.h>
+#include <wininet.h>
-#include "wine/test.h"
+#include <wine/test.h>
#define TEST_URL "http://www.winehq.org/site/about#hi"
#define TEST_URL3 "file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml"
{"http://www.winehq.org?test=123",
0, 4, INTERNET_SCHEME_HTTP, 7, 14, 23, 80, -1, 0, -1, 0, 21, 0, 21, 9,
"http", "www.winehq.org", "", "", "", "?test=123"},
+ {"http://www.winehq.org/myscript.php;test=123",
+ 0, 4, INTERNET_SCHEME_HTTP, 7, 14, 23, 80, -1, 0, -1, 0, 21, 22, -1, 0,
+ "http", "www.winehq.org", "", "", "/myscript.php;test=123", ""},
+ {"HtTp://www.winehq.org/scheme",
+ 0, 4, INTERNET_SCHEME_HTTP, 7, 14, 23, 80, -1, 0, -1, 0, 21, 7, -1, 0,
+ "HtTp", "www.winehq.org", "", "", "/scheme", ""},
{"file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml",
0, 4, INTERNET_SCHEME_FILE, -1, 0, -1, 0, -1, 0, -1, 0, 7, 55, -1, 0,
"file", "", "", "", "C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml", ""},
{"file:///C:/Program%20Files/Atmel/./Asdf.xml",
0, 4, INTERNET_SCHEME_FILE, -1, 0, -1, 0, -1, 0, -1, 0, 7, 36, -1, 0,
"file", "", "", "", "C:\\Program Files\\Atmel\\.\\Asdf.xml", ""},
+ {"C:\\file.txt",
+ 0, 1, INTERNET_SCHEME_UNKNOWN, -1, 0, -1, 0, -1, 0, -1, 0, 2, 9, -1, 0,
+ "C", "", "", "", "\\file.txt", ""}
};
static const WCHAR *w_str_of(const char *str)
ret, GLE);
copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024);
- ret = InternetCrackUrl("about://host/blank", 0,0,&urlComponents);
+ ret = InternetCrackUrlA("about://host/blank", 0,0,&urlComponents);
ok(ret, "InternetCrackUrl failed with %d\n", GetLastError());
ok(!strcmp(urlComponents.lpszScheme, "about"), "lpszScheme was \"%s\" instead of \"about\"\n", urlComponents.lpszScheme);
ok(!strcmp(urlComponents.lpszHostName, "host"), "lpszHostName was \"%s\" instead of \"host\"\n", urlComponents.lpszHostName);
/* try a NULL lpszUrl */
SetLastError(0xdeadbeef);
copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024);
- ret = InternetCrackUrl(NULL, 0, 0, &urlComponents);
+ ret = InternetCrackUrlA(NULL, 0, 0, &urlComponents);
GLE = GetLastError();
ok(ret == FALSE, "Expected InternetCrackUrl to fail\n");
ok(GLE == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GLE);
*/
SetLastError(0xdeadbeef);
copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024);
- ret = InternetCrackUrl("", 0, 0, &urlComponents);
+ ret = InternetCrackUrlA("", 0, 0, &urlComponents);
GLE = GetLastError();
ok(ret == FALSE, "Expected InternetCrackUrl to fail\n");
ok(GLE != 0xdeadbeef && GLE != ERROR_SUCCESS, "Expected GLE to represent a failure\n");
SetLastError(0xdeadbeef);
urlComponents.dwStructSize = 0;
ret = InternetCrackUrlA(TEST_URL, 0, 0, &urlComponents);
+ GLE = GetLastError();
ok(ret == FALSE, "Expected InternetCrackUrl to fail\n");
ok(GLE != 0xdeadbeef && GLE != ERROR_SUCCESS, "Expected GLE to represent a failure\n");
SetLastError(0xdeadbeef);
urlComponents.dwStructSize = sizeof(urlComponents) + 1;
ret = InternetCrackUrlA(TEST_URL, 0, 0, &urlComponents);
+ GLE = GetLastError();
ok(ret == FALSE, "Expected InternetCrackUrl to fail\n");
ok(GLE != 0xdeadbeef && GLE != ERROR_SUCCESS, "Expected GLE to represent a failure\n");
+
+ SetLastError(0xdeadbeef);
+ memset(&urlComponents, 0, sizeof(urlComponents));
+ urlComponents.dwStructSize = sizeof(urlComponents);
+ ret = InternetCrackUrlA("file.txt", 0, 0, &urlComponents);
+ GLE = GetLastError();
+ ok(ret == FALSE, "Expected InternetCrackUrl to fail\n");
+ ok(GLE == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "Expected GLE to represent a failure\n");
+
+ SetLastError(0xdeadbeef);
+ memset(&urlComponents, 0, sizeof(urlComponents));
+ urlComponents.dwStructSize = sizeof(urlComponents);
+ ret = InternetCrackUrlA("www.winehq.org", 0, 0, &urlComponents);
+ GLE = GetLastError();
+ ok(ret == FALSE, "Expected InternetCrackUrl to fail\n");
+ ok(GLE == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "Expected GLE to represent a failure\n");
}
static void InternetCrackUrlW_test(void)
comp.dwExtraInfoLength = sizeof(extra)/sizeof(extra[0]);
r = InternetCrackUrlW(url2, 0, 0, &comp);
- todo_wine {
ok(!r, "InternetCrackUrl should have failed\n");
ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME,
"InternetCrackUrl should have failed with error ERROR_INTERNET_UNRECOGNIZED_SCHEME instead of error %d\n",
GetLastError());
- }
/* Test to see whether cracking a URL without a filename initializes urlpart */
urlpart[0]=0xba;
ok( urlpart[0] == 0, "urlpart should be empty\n");
}
-static void fill_url_components(LPURL_COMPONENTS lpUrlComponents)
+static void fill_url_components(URL_COMPONENTSA *lpUrlComponents)
{
static CHAR http[] = "http",
winehq[] = "www.winehq.org",
site_about[] = "/site/about",
empty[] = "";
- lpUrlComponents->dwStructSize = sizeof(URL_COMPONENTS);
+ lpUrlComponents->dwStructSize = sizeof(URL_COMPONENTSA);
lpUrlComponents->lpszScheme = http;
lpUrlComponents->dwSchemeLength = strlen(lpUrlComponents->lpszScheme);
lpUrlComponents->nScheme = INTERNET_SCHEME_HTTP;
static void InternetCreateUrlA_test(void)
{
- URL_COMPONENTS urlComp;
+ URL_COMPONENTSA urlComp;
LPSTR szUrl;
DWORD len = -1;
BOOL ret;
ok(len == -1, "Expected len -1, got %d\n", len);
/* test zero'ed lpUrlComponents */
- ZeroMemory(&urlComp, sizeof(URL_COMPONENTS));
+ ZeroMemory(&urlComp, sizeof(urlComp));
SetLastError(0xdeadbeef);
ret = InternetCreateUrlA(&urlComp, 0, NULL, &len);
ok(!ret, "Expected failure\n");
ok(!ret, "Expected failure\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
- ok(len == -1, "Expected len -1, got %d\n", len);
/* test valid lpUrlComponents, empty szUrl
* lpdwUrlLength is size of buffer required on exit, including
HeapFree(GetProcessHeap(), 0, szUrl);
memset(&urlComp, 0, sizeof(urlComp));
- urlComp.dwStructSize = sizeof(URL_COMPONENTS);
+ urlComp.dwStructSize = sizeof(urlComp);
urlComp.lpszScheme = http;
urlComp.dwSchemeLength = 0;
urlComp.nScheme = INTERNET_SCHEME_HTTP;
HeapFree(GetProcessHeap(), 0, szUrl);
memset(&urlComp, 0, sizeof(urlComp));
- urlComp.dwStructSize = sizeof(URL_COMPONENTS);
+ urlComp.dwStructSize = sizeof(urlComp);
urlComp.lpszScheme = https;
urlComp.dwSchemeLength = 0;
urlComp.nScheme = INTERNET_SCHEME_HTTP;
HeapFree(GetProcessHeap(), 0, szUrl);
memset(&urlComp, 0, sizeof(urlComp));
- urlComp.dwStructSize = sizeof(URL_COMPONENTS);
+ urlComp.dwStructSize = sizeof(urlComp);
urlComp.lpszScheme = about;
urlComp.dwSchemeLength = 5;
urlComp.lpszUrlPath = blank;
HeapFree(GetProcessHeap(), 0, szUrl);
memset(&urlComp, 0, sizeof(urlComp));
- urlComp.dwStructSize = sizeof(URL_COMPONENTS);
+ urlComp.dwStructSize = sizeof(urlComp);
urlComp.lpszScheme = about;
urlComp.lpszHostName = host;
urlComp.lpszUrlPath = blank;
HeapFree(GetProcessHeap(), 0, szUrl);
memset(&urlComp, 0, sizeof(urlComp));
- urlComp.dwStructSize = sizeof(URL_COMPONENTS);
+ urlComp.dwStructSize = sizeof(urlComp);
urlComp.nPort = 8080;
urlComp.lpszScheme = about;
len = strlen(CREATE_URL11);
HeapFree(GetProcessHeap(), 0, szUrl);
memset(&urlComp, 0, sizeof(urlComp));
- urlComp.dwStructSize = sizeof(URL_COMPONENTS);
+ urlComp.dwStructSize = sizeof(urlComp);
urlComp.lpszScheme = http;
urlComp.dwSchemeLength = 0;
urlComp.nScheme = INTERNET_SCHEME_HTTP;
HeapFree(GetProcessHeap(), 0, szUrl);
memset(&urlComp, 0, sizeof(urlComp));
- urlComp.dwStructSize = sizeof(URL_COMPONENTS);
+ urlComp.dwStructSize = sizeof(urlComp);
urlComp.lpszScheme = http;
urlComp.dwSchemeLength = strlen(urlComp.lpszScheme);
urlComp.lpszHostName = localhost;
HeapFree(GetProcessHeap(), 0, szUrl);
}
+static void InternetCanonicalizeUrl_test(void)
+{
+ char src[] = "http://www.winehq.org/%27/ /./>/#> ";
+ char dst[64];
+ DWORD dstlen;
+
+ dstlen = sizeof(dst);
+ InternetCanonicalizeUrlA(src, dst, &dstlen, 0);
+ ok(strcmp(dst, "http://www.winehq.org/%27/%20/%3E/#>") == 0, "Got \"%s\"\n", dst);
+
+ /* despite what MSDN says, ICU_BROWSER_MODE seems to be ignored */
+ dstlen = sizeof(dst);
+ InternetCanonicalizeUrlA(src, dst, &dstlen, ICU_BROWSER_MODE);
+ ok(strcmp(dst, "http://www.winehq.org/%27/%20/%3E/#>") == 0, "Got \"%s\"\n", dst);
+
+ /* ICU_ESCAPE is supposed to be ignored */
+ dstlen = sizeof(dst);
+ InternetCanonicalizeUrlA(src, dst, &dstlen, ICU_ESCAPE);
+ ok(strcmp(dst, "http://www.winehq.org/%27/%20/%3E/#>") == 0, "Got \"%s\"\n", dst);
+
+ dstlen = sizeof(dst);
+ InternetCanonicalizeUrlA(src, dst, &dstlen, ICU_DECODE);
+ ok(strcmp(dst, "http://www.winehq.org/'/%20/%3E/#>") == 0, "Got \"%s\"\n", dst);
+
+ dstlen = sizeof(dst);
+ InternetCanonicalizeUrlA(src, dst, &dstlen, ICU_ENCODE_PERCENT);
+ ok(strcmp(dst, "http://www.winehq.org/%2527/%20/%3E/#>") == 0, "Got \"%s\"\n", dst);
+
+ dstlen = sizeof(dst);
+ InternetCanonicalizeUrlA(src, dst, &dstlen, ICU_ENCODE_SPACES_ONLY);
+ ok(strcmp(dst, "http://www.winehq.org/%27/%20/>/#>") == 0, "Got \"%s\"\n", dst);
+
+ dstlen = sizeof(dst);
+ InternetCanonicalizeUrlA(src, dst, &dstlen, ICU_NO_ENCODE);
+ ok(strcmp(dst, "http://www.winehq.org/%27/ />/#>") == 0, "Got \"%s\"\n", dst);
+
+ dstlen = sizeof(dst);
+ InternetCanonicalizeUrlA(src, dst, &dstlen, ICU_NO_META);
+ ok(strcmp(dst, "http://www.winehq.org/%27/%20/./%3E/#>") == 0, "Got \"%s\"\n", dst);
+}
+
START_TEST(url)
{
int i;
InternetCrackUrl_test();
InternetCrackUrlW_test();
InternetCreateUrlA_test();
+ InternetCanonicalizeUrl_test();
}