urlmon: Fix handling of mailto URIs in CoInternetCombineUrlEx.

Hans Leidekker hans at codeweavers.com
Wed Mar 27 04:43:53 CDT 2013


---
 dlls/urlmon/tests/uri.c |   63 +++++++++++++++++++++++++++++++++++++++++++----
 dlls/urlmon/uri.c       |   15 ++++++++---
 2 files changed, 69 insertions(+), 9 deletions(-)

diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c
index e5faa81..29bd859 100644
--- a/dlls/urlmon/tests/uri.c
+++ b/dlls/urlmon/tests/uri.c
@@ -7005,8 +7005,61 @@ static const uri_combine_test uri_combine_tests[] = {
             {URL_SCHEME_FILE,S_OK},
             {URLZONE_INVALID,E_NOTIMPL}
         }
+    },
+    {   "http://winehq.org",0,
+        "mailto://",0,
+        0,S_OK,FALSE,
+        {
+            {"mailto:",S_OK},
+            {"",S_FALSE},
+            {"mailto:",S_OK},
+            {"",S_FALSE},
+            {"",S_FALSE},
+            {"",S_FALSE},
+            {"",S_FALSE},
+            {"",S_FALSE},
+            {"",S_FALSE},
+            {"",S_FALSE},
+            {"",S_FALSE},
+            {"mailto://",S_OK,FALSE,"mailto:"},
+            {"mailto",S_OK},
+            {"",S_FALSE},
+            {"",S_FALSE}
+        },
+        {
+            {Uri_HOST_UNKNOWN,S_OK},
+            {0,S_FALSE},
+            {URL_SCHEME_MAILTO,S_OK},
+            {URLZONE_INVALID,E_NOTIMPL}
+        }
+    },
+    {   "http://winehq.org",0,
+        "mailto://[email protected]",0,
+        0,S_OK,FALSE,
+        {
+            {"mailto:a at b.com",S_OK},
+            {"",S_FALSE},
+            {"mailto:a at b.com",S_OK},
+            {"",S_FALSE},
+            {".com",S_OK},
+            {"",S_FALSE},
+            {"",S_FALSE},
+            {"",S_FALSE},
+            {"a at b.com",S_OK},
+            {"a at b.com",S_OK},
+            {"",S_FALSE},
+            {"mailto://[email protected]",S_OK,FALSE,"mailto:a at b.com"},
+            {"mailto",S_OK},
+            {"",S_FALSE},
+            {"",S_FALSE}
+        },
+        {
+            {Uri_HOST_UNKNOWN,S_OK},
+            {0,S_FALSE},
+            {URL_SCHEME_MAILTO,S_OK},
+            {URLZONE_INVALID,E_NOTIMPL}
+        }
     }
-
 };
 
 typedef struct _uri_parse_test {
@@ -10317,7 +10370,7 @@ static void test_CoInternetCombineIUri(void) {
                             todo_wine {
                                 ok(!strcmp_aw(prop.value, received) ||
                                    broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
-                                    "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
+                                    "Error: Expected \"%s\" but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
                                     prop.value, wine_dbgstr_w(received), i, j);
                             }
                         } else {
@@ -10326,7 +10379,7 @@ static void test_CoInternetCombineIUri(void) {
                                 hr, prop.expected, i, j);
                             ok(!strcmp_aw(prop.value, received) ||
                                broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
-                                "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
+                                "Error: Expected \"%s\" but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
                                 prop.value, wine_dbgstr_w(received), i, j);
                         }
                         SysFreeString(received);
@@ -10634,7 +10687,7 @@ static void test_CoInternetCombineUrlEx(void) {
                         todo_wine {
                             ok(!strcmp_aw(value, received) ||
                                broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
-                                "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
+                                "Error: Expected \"%s\" but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
                                 value, wine_dbgstr_w(received), i, j);
                         }
                     } else {
@@ -10643,7 +10696,7 @@ static void test_CoInternetCombineUrlEx(void) {
                             hr, prop.expected, i, j);
                         ok(!strcmp_aw(value, received) ||
                            broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
-                            "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
+                            "Error: Expected \"%s\" but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
                             value, wine_dbgstr_w(received), i, j);
                     }
                     SysFreeString(received);
diff --git a/dlls/urlmon/uri.c b/dlls/urlmon/uri.c
index 0f6ee31..c6b5166 100644
--- a/dlls/urlmon/uri.c
+++ b/dlls/urlmon/uri.c
@@ -422,7 +422,7 @@ static inline BOOL is_hierarchical_uri(const WCHAR **ptr, const parse_data *data
     else if(is_hierarchical_scheme(data->scheme_type) && (*ptr)[0] == '\\' && (*ptr)[1] == '\\') {
         *ptr += 2;
         return TRUE;
-    } else if(check_hierarchical(ptr))
+    } else if(data->scheme_type != URL_SCHEME_MAILTO && check_hierarchical(ptr))
         return TRUE;
 
     *ptr = start;
@@ -2980,6 +2980,9 @@ static BOOL canonicalize_path_opaque(const parse_data *data, Uri *uri, DWORD fla
     const BOOL known_scheme = data->scheme_type != URL_SCHEME_UNKNOWN;
     const BOOL is_file = data->scheme_type == URL_SCHEME_FILE;
     const BOOL is_mk = data->scheme_type == URL_SCHEME_MK;
+    const BOOL is_javascript = data->scheme_type == URL_SCHEME_JAVASCRIPT;
+    const BOOL is_mailto = data->scheme_type == URL_SCHEME_MAILTO;
+    DWORD offset = 0;
 
     if(!data->path) {
         uri->path_start = -1;
@@ -2996,7 +2999,7 @@ static BOOL canonicalize_path_opaque(const parse_data *data, Uri *uri, DWORD fla
     }
 
     /* For javascript: URIs, simply copy path part without any canonicalization */
-    if(data->scheme_type == URL_SCHEME_JAVASCRIPT) {
+    if(is_javascript) {
         if(!computeOnly)
             memcpy(uri->canon_uri+uri->canon_len, data->path, data->path_len*sizeof(WCHAR));
         uri->path_len = data->path_len;
@@ -3007,7 +3010,11 @@ static BOOL canonicalize_path_opaque(const parse_data *data, Uri *uri, DWORD fla
     /* Windows doesn't allow a "//" to appear after the scheme
      * of a URI, if it's an opaque URI.
      */
-    if(data->scheme && *(data->path) == '/' && *(data->path+1) == '/') {
+    if (is_mailto && *(data->path) == '/' && *(data->path+1) == '/') {
+        if (!*(data->path+2)) uri->path_start = -1;
+        offset += 2;
+    }
+    else if(data->scheme && *(data->path) == '/' && *(data->path+1) == '/') {
         /* So it inserts a "/." before the "//" if it exists. */
         if(!computeOnly) {
             uri->canon_uri[uri->canon_len] = '/';
@@ -3017,7 +3024,7 @@ static BOOL canonicalize_path_opaque(const parse_data *data, Uri *uri, DWORD fla
         uri->canon_len += 2;
     }
 
-    for(ptr = data->path; ptr < data->path+data->path_len; ++ptr) {
+    for(ptr = data->path+offset; ptr < data->path+data->path_len; ++ptr) {
         BOOL do_default_action = TRUE;
 
         if(*ptr == '%' && known_scheme) {
-- 
1.7.10.4






More information about the wine-patches mailing list