mirror of
https://github.com/reactos/wine.git
synced 2024-11-24 12:20:07 +00:00
urlmon: Skip query and hash part in find_mime_from_url.
This commit is contained in:
parent
1449090985
commit
9351e225bb
@ -422,20 +422,15 @@ static BOOL application_octet_stream_filter(const BYTE *b, DWORD size)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static HRESULT find_mime_from_url(const WCHAR *url, WCHAR **ret)
|
||||
static HRESULT find_mime_from_ext(const WCHAR *ext, WCHAR **ret)
|
||||
{
|
||||
const WCHAR *ptr;
|
||||
DWORD res, size;
|
||||
WCHAR mime[64];
|
||||
HKEY hkey;
|
||||
|
||||
static const WCHAR content_typeW[] = {'C','o','n','t','e','n','t',' ','T','y','p','e','\0'};
|
||||
|
||||
ptr = strrchrW(url, '.');
|
||||
if(!ptr)
|
||||
return E_FAIL;
|
||||
|
||||
res = RegOpenKeyW(HKEY_CLASSES_ROOT, ptr, &hkey);
|
||||
res = RegOpenKeyW(HKEY_CLASSES_ROOT, ext, &hkey);
|
||||
if(res != ERROR_SUCCESS)
|
||||
return HRESULT_FROM_WIN32(res);
|
||||
|
||||
@ -452,6 +447,41 @@ static HRESULT find_mime_from_url(const WCHAR *url, WCHAR **ret)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT find_mime_from_url(const WCHAR *url, WCHAR **ret)
|
||||
{
|
||||
const WCHAR *ptr, *end_ptr;
|
||||
WCHAR *ext = NULL;
|
||||
HRESULT hres;
|
||||
|
||||
for(end_ptr = url; *end_ptr; end_ptr++) {
|
||||
if(*end_ptr == '?' || *end_ptr == '#')
|
||||
break;
|
||||
}
|
||||
|
||||
for(ptr = end_ptr; ptr >= url; ptr--) {
|
||||
if(*ptr == '.')
|
||||
break;
|
||||
}
|
||||
|
||||
if(ptr < url)
|
||||
return E_FAIL;
|
||||
|
||||
if(*end_ptr) {
|
||||
unsigned len = end_ptr-ptr;
|
||||
|
||||
ext = heap_alloc((len+1)*sizeof(WCHAR));
|
||||
if(!ext)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
memcpy(ext, ptr, len*sizeof(WCHAR));
|
||||
ext[len] = 0;
|
||||
}
|
||||
|
||||
hres = find_mime_from_ext(ext ? ext : ptr, ret);
|
||||
heap_free(ext);
|
||||
return hres;
|
||||
}
|
||||
|
||||
static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
|
||||
static const WCHAR text_richtextW[] = {'t','e','x','t','/','r','i','c','h','t','e','x','t',0};
|
||||
static const WCHAR text_xmlW[] = {'t','e','x','t','/','x','m','l',0};
|
||||
|
@ -466,10 +466,15 @@ static const struct {
|
||||
const char *url;
|
||||
const char *mime;
|
||||
HRESULT hres;
|
||||
BOOL broken_failure;
|
||||
const char *broken_mime;
|
||||
} mime_tests[] = {
|
||||
{"res://mshtml.dll/blank.htm", "text/html", S_OK},
|
||||
{"index.htm", "text/html", S_OK},
|
||||
{"file://c:\\Index.htm", "text/html", S_OK},
|
||||
{"file://c:\\Index.htm?q=test", "text/html", S_OK, TRUE},
|
||||
{"file://c:\\Index.htm#hash_part", "text/html", S_OK, TRUE},
|
||||
{"file://c:\\Index.htm#hash_part.txt", "text/html", S_OK, FALSE, "text/plain"},
|
||||
{"file://some%20file%2ejpg", NULL, E_FAIL},
|
||||
{"http://www.winehq.org", NULL, __HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)},
|
||||
{"about:blank", NULL, E_FAIL},
|
||||
@ -713,9 +718,13 @@ static void test_FindMimeFromData(void)
|
||||
url = a2w(mime_tests[i].url);
|
||||
hres = pFindMimeFromData(NULL, url, NULL, 0, NULL, 0, &mime, 0);
|
||||
if(mime_tests[i].mime) {
|
||||
ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
|
||||
ok(!strcmp_wa(mime, mime_tests[i].mime), "[%d] wrong mime: %s\n", i, wine_dbgstr_w(mime));
|
||||
CoTaskMemFree(mime);
|
||||
ok(hres == S_OK || broken(mime_tests[i].broken_failure), "[%d] FindMimeFromData failed: %08x\n", i, hres);
|
||||
if(hres == S_OK) {
|
||||
ok(!strcmp_wa(mime, mime_tests[i].mime)
|
||||
|| broken(mime_tests[i].broken_mime && !strcmp_wa(mime, mime_tests[i].broken_mime)),
|
||||
"[%d] wrong mime: %s\n", i, wine_dbgstr_w(mime));
|
||||
CoTaskMemFree(mime);
|
||||
}
|
||||
}else {
|
||||
ok(hres == E_FAIL || hres == mime_tests[i].hres,
|
||||
"[%d] FindMimeFromData failed: %08x, expected %08x\n",
|
||||
|
Loading…
Reference in New Issue
Block a user