Thomas Mullaly : urlmon: Improved IUri support for file URIs.

Alexandre Julliard julliard at winehq.org
Wed Nov 3 11:37:04 CDT 2010


Module: wine
Branch: master
Commit: d6e624c7ee0cc64a0e4f4e3d42a99453fcd21028
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d6e624c7ee0cc64a0e4f4e3d42a99453fcd21028

Author: Thomas Mullaly <thomas.mullaly at gmail.com>
Date:   Sun Oct 10 15:40:54 2010 -0400

urlmon: Improved IUri support for file URIs.

---

 dlls/urlmon/tests/uri.c |   29 +++++++++++++++++++++++++++++
 dlls/urlmon/uri.c       |   16 ++++++++++++++--
 2 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c
index cb1ad6f..bf1ed1c 100644
--- a/dlls/urlmon/tests/uri.c
+++ b/dlls/urlmon/tests/uri.c
@@ -4295,6 +4295,35 @@ static const uri_properties uri_tests[] = {
             {URL_SCHEME_MK,S_OK,FALSE},
             {URLZONE_INVALID,E_NOTIMPL,FALSE}
         }
+    },
+    /* Two '\' are added to the URI when USE_DOS_PATH is set, and it's a UNC path. */
+    {   "file://server/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
+        Uri_HAS_ABSOLUTE_URI|Uri_HAS_AUTHORITY|Uri_HAS_DISPLAY_URI|Uri_HAS_EXTENSION|Uri_HAS_HOST|
+        Uri_HAS_PATH|Uri_HAS_PATH_AND_QUERY|Uri_HAS_RAW_URI|Uri_HAS_SCHEME_NAME|Uri_HAS_HOST_TYPE|
+        Uri_HAS_SCHEME, FALSE,
+        {
+            {"file://\\\\server\\dir\\index.html",S_OK,FALSE},
+            {"server",S_OK,FALSE},
+            {"file://\\\\server\\dir\\index.html",S_OK,FALSE},
+            {"",S_FALSE,FALSE},
+            {".html",S_OK,FALSE},
+            {"",S_FALSE,FALSE},
+            {"server",S_OK,FALSE},
+            {"",S_FALSE,FALSE},
+            {"\\dir\\index.html",S_OK,FALSE},
+            {"\\dir\\index.html",S_OK,FALSE},
+            {"",S_FALSE,FALSE},
+            {"file://server/dir/index.html",S_OK,FALSE},
+            {"file",S_OK,FALSE},
+            {"",S_FALSE,FALSE},
+            {"",S_FALSE,FALSE}
+        },
+        {
+            {Uri_HOST_DNS,S_OK,FALSE},
+            {0,S_FALSE,FALSE},
+            {URL_SCHEME_FILE,S_OK,FALSE},
+            {URLZONE_INVALID,E_NOTIMPL,FALSE}
+        }
     }
 };
 
diff --git a/dlls/urlmon/uri.c b/dlls/urlmon/uri.c
index 6aaa133..ad50fb2 100644
--- a/dlls/urlmon/uri.c
+++ b/dlls/urlmon/uri.c
@@ -2348,6 +2348,9 @@ static BOOL canonicalize_userinfo(const parse_data *data, Uri *uri, DWORD flags,
  *      it isn't an unknown scheme type.
  *
  *  4)  If it's a file scheme and the host is "localhost" it's removed.
+ *
+ *  5)  If it's a file scheme and Uri_CREATE_FILE_USE_DOS_PATH is set,
+ *      then the UNC path characters are added before the host name.
  */
 static BOOL canonicalize_reg_name(const parse_data *data, Uri *uri,
                                   DWORD flags, BOOL computeOnly) {
@@ -2356,8 +2359,6 @@ static BOOL canonicalize_reg_name(const parse_data *data, Uri *uri,
     const WCHAR *ptr;
     const BOOL known_scheme = data->scheme_type != URL_SCHEME_UNKNOWN;
 
-    uri->host_start = uri->canon_len;
-
     if(data->scheme_type == URL_SCHEME_FILE &&
        data->host_len == lstrlenW(localhostW)) {
         if(!StrCmpNIW(data->host, localhostW, data->host_len)) {
@@ -2368,6 +2369,17 @@ static BOOL canonicalize_reg_name(const parse_data *data, Uri *uri,
         }
     }
 
+    if(data->scheme_type == URL_SCHEME_FILE && flags & Uri_CREATE_FILE_USE_DOS_PATH) {
+        if(!computeOnly) {
+            uri->canon_uri[uri->canon_len] = '\\';
+            uri->canon_uri[uri->canon_len+1] = '\\';
+        }
+        uri->canon_len += 2;
+        uri->authority_start = uri->canon_len;
+    }
+
+    uri->host_start = uri->canon_len;
+
     for(ptr = data->host; ptr < data->host+data->host_len; ++ptr) {
         if(*ptr == '%' && known_scheme) {
             WCHAR val = decode_pct_val(ptr);




More information about the wine-cvs mailing list