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;
|
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;
|
DWORD res, size;
|
||||||
WCHAR mime[64];
|
WCHAR mime[64];
|
||||||
HKEY hkey;
|
HKEY hkey;
|
||||||
|
|
||||||
static const WCHAR content_typeW[] = {'C','o','n','t','e','n','t',' ','T','y','p','e','\0'};
|
static const WCHAR content_typeW[] = {'C','o','n','t','e','n','t',' ','T','y','p','e','\0'};
|
||||||
|
|
||||||
ptr = strrchrW(url, '.');
|
res = RegOpenKeyW(HKEY_CLASSES_ROOT, ext, &hkey);
|
||||||
if(!ptr)
|
|
||||||
return E_FAIL;
|
|
||||||
|
|
||||||
res = RegOpenKeyW(HKEY_CLASSES_ROOT, ptr, &hkey);
|
|
||||||
if(res != ERROR_SUCCESS)
|
if(res != ERROR_SUCCESS)
|
||||||
return HRESULT_FROM_WIN32(res);
|
return HRESULT_FROM_WIN32(res);
|
||||||
|
|
||||||
|
@ -452,6 +447,41 @@ static HRESULT find_mime_from_url(const WCHAR *url, WCHAR **ret)
|
||||||
return S_OK;
|
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_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_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};
|
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 *url;
|
||||||
const char *mime;
|
const char *mime;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
BOOL broken_failure;
|
||||||
|
const char *broken_mime;
|
||||||
} mime_tests[] = {
|
} mime_tests[] = {
|
||||||
{"res://mshtml.dll/blank.htm", "text/html", S_OK},
|
{"res://mshtml.dll/blank.htm", "text/html", S_OK},
|
||||||
{"index.htm", "text/html", S_OK},
|
{"index.htm", "text/html", S_OK},
|
||||||
{"file://c:\\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},
|
{"file://some%20file%2ejpg", NULL, E_FAIL},
|
||||||
{"http://www.winehq.org", NULL, __HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)},
|
{"http://www.winehq.org", NULL, __HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)},
|
||||||
{"about:blank", NULL, E_FAIL},
|
{"about:blank", NULL, E_FAIL},
|
||||||
|
@ -713,9 +718,13 @@ static void test_FindMimeFromData(void)
|
||||||
url = a2w(mime_tests[i].url);
|
url = a2w(mime_tests[i].url);
|
||||||
hres = pFindMimeFromData(NULL, url, NULL, 0, NULL, 0, &mime, 0);
|
hres = pFindMimeFromData(NULL, url, NULL, 0, NULL, 0, &mime, 0);
|
||||||
if(mime_tests[i].mime) {
|
if(mime_tests[i].mime) {
|
||||||
ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
|
ok(hres == S_OK || broken(mime_tests[i].broken_failure), "[%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));
|
if(hres == S_OK) {
|
||||||
CoTaskMemFree(mime);
|
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 {
|
}else {
|
||||||
ok(hres == E_FAIL || hres == mime_tests[i].hres,
|
ok(hres == E_FAIL || hres == mime_tests[i].hres,
|
||||||
"[%d] FindMimeFromData failed: %08x, expected %08x\n",
|
"[%d] FindMimeFromData failed: %08x, expected %08x\n",
|
||||||
|
|
Loading…
Reference in New Issue