Jacek Caban : urlmon: Properly compare file URIs.
Alexandre Julliard
julliard at winehq.org
Fri Nov 25 10:27:33 CST 2011
Module: wine
Branch: master
Commit: e0f6b95d44f8208d2dce75278eb88e6eb57fe744
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e0f6b95d44f8208d2dce75278eb88e6eb57fe744
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri Nov 25 15:58:37 2011 +0100
urlmon: Properly compare file URIs.
---
dlls/urlmon/uri.c | 59 +++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 51 insertions(+), 8 deletions(-)
diff --git a/dlls/urlmon/uri.c b/dlls/urlmon/uri.c
index c0233bf..55488d9 100644
--- a/dlls/urlmon/uri.c
+++ b/dlls/urlmon/uri.c
@@ -3859,6 +3859,49 @@ static HRESULT validate_components(const UriBuilder *builder, parse_data *data,
return S_OK;
}
+static HRESULT compare_file_paths(const Uri *a, const Uri *b, BOOL *ret)
+{
+ WCHAR *canon_path_a, *canon_path_b;
+ DWORD len_a, len_b;
+
+ if(!a->path_len) {
+ *ret = !b->path_len;
+ return S_OK;
+ }
+
+ if(!b->path_len) {
+ *ret = FALSE;
+ return S_OK;
+ }
+
+ /* Fast path */
+ if(a->path_len == b->path_len && !memicmpW(a->canon_uri+a->path_start, b->canon_uri+b->path_start, a->path_len)) {
+ *ret = TRUE;
+ return S_OK;
+ }
+
+ len_a = canonicalize_path_hierarchical(a->canon_uri+a->path_start, a->path_len, a->scheme_type, FALSE, 0, NULL);
+ len_b = canonicalize_path_hierarchical(b->canon_uri+b->path_start, b->path_len, b->scheme_type, FALSE, 0, NULL);
+
+ canon_path_a = heap_alloc(len_a*sizeof(WCHAR));
+ if(!canon_path_a)
+ return E_OUTOFMEMORY;
+ canon_path_b = heap_alloc(len_b*sizeof(WCHAR));
+ if(!canon_path_b) {
+ heap_free(canon_path_a);
+ return E_OUTOFMEMORY;
+ }
+
+ len_a = canonicalize_path_hierarchical(a->canon_uri+a->path_start, a->path_len, a->scheme_type, FALSE, 0, canon_path_a);
+ len_b = canonicalize_path_hierarchical(b->canon_uri+b->path_start, b->path_len, b->scheme_type, FALSE, 0, canon_path_b);
+
+ *ret = len_a == len_b && !memicmpW(canon_path_a, canon_path_b, len_a);
+
+ heap_free(canon_path_a);
+ heap_free(canon_path_b);
+ return S_OK;
+}
+
/* Checks if the two Uri's are logically equivalent. It's a simple
* comparison, since they are both of type Uri, and it can access
* the properties of each Uri directly without the need to go
@@ -3867,19 +3910,13 @@ static HRESULT validate_components(const UriBuilder *builder, parse_data *data,
static HRESULT compare_uris(const Uri *a, const Uri *b, BOOL *ret) {
const BOOL known_scheme = a->scheme_type != URL_SCHEME_UNKNOWN;
const BOOL are_hierarchical = a->authority_start > -1 && b->authority_start > -1;
+ HRESULT hres;
*ret = FALSE;
if(a->scheme_type != b->scheme_type)
return S_OK;
- if(a->scheme_type == URL_SCHEME_FILE) {
- if(a->canon_len == b->canon_len) {
- *ret = !StrCmpIW(a->canon_uri, b->canon_uri);
- return S_OK;
- }
- }
-
/* Only compare the scheme names (if any) if their unknown scheme types. */
if(!known_scheme) {
if((a->scheme_start > -1 && b->scheme_start > -1) &&
@@ -3927,7 +3964,13 @@ static HRESULT compare_uris(const Uri *a, const Uri *b, BOOL *ret) {
* would still evaluate to TRUE, but, only if they are both hierarchical
* URIs.
*/
- if((a->path_start > -1 && b->path_start > -1) &&
+ if(a->scheme_type == URL_SCHEME_FILE) {
+ BOOL cmp;
+
+ hres = compare_file_paths(a, b, &cmp);
+ if(FAILED(hres) || !cmp)
+ return hres;
+ } else if((a->path_start > -1 && b->path_start > -1) &&
(a->path_len == b->path_len)) {
if(StrCmpNW(a->canon_uri+a->path_start, b->canon_uri+b->path_start, a->path_len))
return S_OK;
More information about the wine-cvs
mailing list