Commit 796cf171 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

urlmon: Added text/html filter.

parent c73c3362
......@@ -350,6 +350,14 @@ static BYTE data3[] = {0,0,0};
static BYTE data4[] = {'t','e','s',0xfa,'t',' ','d','a','t','a','\n',0,0};
static BYTE data5[] = {0xa,0xa,0xa,'x',32,'x',0};
static BYTE data6[] = {0xfa,0xfa,0xfa,0xfa,'\n','\r','\t','x','x','x',1};
static BYTE data7[] = "<html>blahblah";
static BYTE data8[] = {'t','e','s',0xfa,'t',' ','<','h','t','m','l','>','d','a','t','a','\n',0,0};
static BYTE data9[] = {'t','e',0,'s',0xfa,'t',' ','<','h','t','m','l','>','d','a','t','a','\n',0,0};
static BYTE data10[] = "<HtmL>blahblah";
static BYTE data11[] = "blah<HTML>blahblah";
static BYTE data12[] = "blah<HTMLblahblah";
static BYTE data13[] = "blahHTML>blahblah";
static BYTE data14[] = "blah<HTMblahblah";
static const struct {
BYTE *data;
......@@ -361,7 +369,15 @@ static const struct {
{data3, sizeof(data3), mimeAppOctetStream},
{data4, sizeof(data4), mimeAppOctetStream},
{data5, sizeof(data5), mimeTextPlain},
{data6, sizeof(data6), mimeTextPlain}
{data6, sizeof(data6), mimeTextPlain},
{data7, sizeof(data7), mimeTextHtml},
{data8, sizeof(data8), mimeTextHtml},
{data9, sizeof(data9), mimeTextHtml},
{data10, sizeof(data10), mimeTextHtml},
{data11, sizeof(data11), mimeTextHtml},
{data12, sizeof(data12), mimeTextHtml},
{data13, sizeof(data13), mimeTextPlain},
{data14, sizeof(data14), mimeTextPlain}
};
static void test_FindMimeFromData(void)
......
......@@ -28,7 +28,6 @@
#define NO_SHLWAPI_REG
#include "shlwapi.h"
#include "wine/debug.h"
#include "wine/unicode.h"
......@@ -397,6 +396,26 @@ void WINAPI ReleaseBindInfo(BINDINFO* pbindinfo)
*
* Determines the Multipurpose Internet Mail Extensions (MIME) type from the data provided.
*/
static BOOL text_html_filter(LPVOID buf, DWORD size)
{
const char *b = buf;
int i;
if(size < 5)
return FALSE;
for(i=0; i < size-5; i++) {
if(b[i] == '<'
&& (b[i+1] == 'h' || b[i+1] == 'H')
&& (b[i+2] == 't' || b[i+2] == 'T')
&& (b[i+3] == 'm' || b[i+3] == 'M')
&& (b[i+4] == 'l' || b[i+4] == 'L'))
return TRUE;
}
return FALSE;
}
static BOOL text_plain_filter(LPVOID buf, DWORD size)
{
UCHAR *ptr;
......@@ -448,6 +467,7 @@ HRESULT WINAPI FindMimeFromData(LPBC pBC, LPCWSTR pwzUrl, LPVOID pBuffer,
LPCWSTR ret = NULL;
int i = 0;
static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
static const WCHAR wszTextPlain[] = {'t','e','x','t','/','p','l','a','i','n','\0'};
static const WCHAR wszAppOctetStream[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
'o','c','t','e','t','-','s','t','r','e','a','m','\0'};
......@@ -456,6 +476,7 @@ HRESULT WINAPI FindMimeFromData(LPBC pBC, LPCWSTR pwzUrl, LPVOID pBuffer,
LPCWSTR mime;
BOOL (*filter)(LPVOID,DWORD);
} mime_filters[] = {
{wszTextHtml, text_html_filter},
{wszTextPlain, text_plain_filter},
{wszAppOctetStream, application_octet_stream_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