Commit 58e8b19d authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

urlmon: Added audio/wav MIME filter.

parent ec565fbf
......@@ -62,6 +62,13 @@ DEFINE_EXPECT(QI_IInternetProtocolInfo);
DEFINE_EXPECT(CreateInstance);
DEFINE_EXPECT(unk_Release);
static const char *debugstr_w(LPCWSTR str)
{
static char buf[1024];
WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL);
return buf;
}
static void test_CreateFormatEnum(void)
{
IEnumFORMATETC *fenum = NULL, *fenum2 = NULL;
......@@ -365,6 +372,7 @@ static const WCHAR mimeAppJava[] = {'a','p','p','l','i','c','a','t','i','o','n',
static const WCHAR mimeAppPdf[] = {'a','p','p','l','i','c','a','t','i','o','n','/','p','d','f',0};
static const WCHAR mimeAppXMSDownload[] =
{'a','p','p','l','i','c','a','t','i','o','n','/','x','-','m','s','d','o','w','n','l','o','a','d',0};
static const WCHAR mimeAudioWav[] = {'a','u','d','i','o','/','w','a','v',0};
static const struct {
LPCWSTR url;
......@@ -454,6 +462,10 @@ static BYTE data71[] = {'{','\\','r','t','f',0};
static BYTE data72[] = {'{','\\','r','t','f'};
static BYTE data73[] = {' ','{','\\','r','t','f',' '};
static BYTE data74[] = {'{','\\','r','t','f','<','h','t','m','l','>',' '};
static BYTE data75[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'W','A','V','E',0xff};
static BYTE data76[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'W','A','V','E'};
static BYTE data77[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'W','A','V',0xff,0xff};
static BYTE data78[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'<','h','t','m','l','>',0xff};
static const struct {
BYTE *data;
......@@ -533,7 +545,11 @@ static const struct {
{data71, sizeof(data71), mimeTextRichtext},
{data72, sizeof(data72), mimeTextPlain},
{data73, sizeof(data73), mimeTextPlain},
{data74, sizeof(data74), mimeTextHtml}
{data74, sizeof(data74), mimeTextHtml},
{data75, sizeof(data75), mimeAudioWav},
{data76, sizeof(data76), mimeTextPlain},
{data77, sizeof(data77), mimeTextPlain},
{data78, sizeof(data78), mimeTextHtml}
};
static void test_FindMimeFromData(void)
......@@ -573,7 +589,7 @@ static void test_FindMimeFromData(void)
hres = FindMimeFromData(NULL, NULL, mime_tests2[i].data, mime_tests2[i].size,
NULL, 0, &mime, 0);
ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
ok(!lstrcmpW(mime, mime_tests2[i].mime), "[%d] wrong mime\n", i);
ok(!lstrcmpW(mime, mime_tests2[i].mime), "[%d] wrong mime: %s\n", i, debugstr_w(mime));
CoTaskMemFree(mime);
hres = FindMimeFromData(NULL, NULL, mime_tests2[i].data, mime_tests2[i].size,
......
......@@ -432,6 +432,13 @@ static BOOL text_html_filter(const BYTE *b, DWORD size)
return FALSE;
}
static BOOL audio_wav_filter(const BYTE *b, DWORD size)
{
return size > 12
&& b[0] == 'R' && b[1] == 'I' && b[2] == 'F' && b[3] == 'F'
&& b[8] == 'W' && b[9] == 'A' && b[10] == 'V' && b[11] == 'E';
}
static BOOL image_gif_filter(const BYTE *b, DWORD size)
{
return size >= 6
......@@ -564,6 +571,7 @@ HRESULT WINAPI FindMimeFromData(LPBC pBC, LPCWSTR pwzUrl, LPVOID pBuffer,
static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
static const WCHAR wszTextRichtext[] = {'t','e','x','t','/','r','i','c','h','t','e','x','t',0};
static const WCHAR wszAudioWav[] = {'a','u','d','i','o','/','w','a','v',0};
static const WCHAR wszImageGif[] = {'i','m','a','g','e','/','g','i','f',0};
static const WCHAR wszImagePjpeg[] = {'i','m','a','g','e','/','p','j','p','e','g',0};
static const WCHAR wszImageTiff[] = {'i','m','a','g','e','/','t','i','f','f',0};
......@@ -591,6 +599,7 @@ HRESULT WINAPI FindMimeFromData(LPBC pBC, LPCWSTR pwzUrl, LPVOID pBuffer,
} mime_filters[] = {
{wszTextHtml, text_html_filter},
{wszTextRichtext, text_richtext_filter},
{wszAudioWav, audio_wav_filter},
{wszImageGif, image_gif_filter},
{wszImagePjpeg, image_pjpeg_filter},
{wszImageTiff, image_tiff_filter},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment