Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
9351e225
Commit
9351e225
authored
Dec 23, 2014
by
Jacek Caban
Committed by
Alexandre Julliard
Dec 23, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
urlmon: Skip query and hash part in find_mime_from_url.
parent
14490909
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
10 deletions
+49
-10
mimefilter.c
dlls/urlmon/mimefilter.c
+37
-7
misc.c
dlls/urlmon/tests/misc.c
+12
-3
No files found.
dlls/urlmon/mimefilter.c
View file @
9351e225
...
...
@@ -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
};
...
...
dlls/urlmon/tests/misc.c
View file @
9351e225
...
...
@@ -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
"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment