Thomas Mullaly : urlmon: Can't set the host of a IUriBuilder to NULL.

Alexandre Julliard julliard at winehq.org
Tue Sep 28 11:13:31 CDT 2010


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

Author: Thomas Mullaly <thomas.mullaly at gmail.com>
Date:   Wed Sep 22 17:32:46 2010 -0400

urlmon: Can't set the host of a IUriBuilder to NULL.

---

 dlls/urlmon/tests/uri.c |   72 ++++++++++++++++++++++++++++++++++++++++++++++-
 dlls/urlmon/uri.c       |   19 +++++++++---
 2 files changed, 85 insertions(+), 6 deletions(-)

diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c
index a32f889..16bb75f 100644
--- a/dlls/urlmon/tests/uri.c
+++ b/dlls/urlmon/tests/uri.c
@@ -5295,6 +5295,72 @@ static const uri_builder_test uri_builder_tests[] = {
             {URL_SCHEME_HTTP,S_OK},
             {URLZONE_INVALID,E_NOTIMPL}
         }
+    },
+    /* Can't set the host name to NULL. */
+    {   "http://google.com/",0,S_OK,FALSE,
+        {
+            {TRUE,NULL,"google.com",Uri_PROPERTY_HOST,E_INVALIDARG,FALSE}
+        },
+        {FALSE},
+        0,S_OK,FALSE,
+        0,S_OK,FALSE,
+        0,0,0,S_OK,FALSE,
+        {
+            {"http://google.com/",S_OK},
+            {"google.com",S_OK},
+            {"http://google.com/",S_OK},
+            {"google.com",S_OK},
+            {"",S_FALSE},
+            {"",S_FALSE},
+            {"google.com",S_OK},
+            {"",S_FALSE},
+            {"/",S_OK},
+            {"/",S_OK},
+            {"",S_FALSE},
+            {"http://google.com/",S_OK},
+            {"http",S_OK},
+            {"",S_FALSE},
+            {"",S_FALSE}
+        },
+        {
+            {Uri_HOST_DNS,S_OK},
+            {80,S_OK},
+            {URL_SCHEME_HTTP,S_OK},
+            {URLZONE_INVALID,E_NOTIMPL}
+        }
+    },
+    /* Can set the host name to an empty string. */
+    {   "http://google.com/",0,S_OK,FALSE,
+        {
+            {TRUE,"",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
+        },
+        {FALSE},
+        0,S_OK,TRUE,
+        0,S_OK,TRUE,
+        0,0,0,S_OK,TRUE,
+        {
+            {"http:///",S_OK},
+            {"",S_OK},
+            {"http:///",S_OK},
+            {"",S_FALSE},
+            {"",S_FALSE},
+            {"",S_FALSE},
+            {"",S_OK},
+            {"",S_FALSE},
+            {"/",S_OK},
+            {"/",S_OK},
+            {"",S_FALSE},
+            {"http:///",S_OK},
+            {"http",S_OK},
+            {"",S_FALSE},
+            {"",S_FALSE}
+        },
+        {
+            {Uri_HOST_UNKNOWN,S_OK},
+            {80,S_OK},
+            {URL_SCHEME_HTTP,S_OK},
+            {URLZONE_INVALID,E_NOTIMPL}
+        }
     }
 };
 
@@ -8025,10 +8091,14 @@ static void test_IUriBuilder(void) {
                 uri_builder_property prop = test.properties[j];
                 if(prop.change) {
                     change_property(builder, &prop, i);
-                    if(prop.property != Uri_PROPERTY_SCHEME_NAME)
+                    if(prop.property != Uri_PROPERTY_SCHEME_NAME &&
+                       prop.property != Uri_PROPERTY_HOST)
                         modified = TRUE;
                     else if(prop.value && *prop.value)
                         modified = TRUE;
+                    else if(prop.value && !*prop.value && prop.property == Uri_PROPERTY_HOST)
+                        /* Host name property can't be NULL, but it can be empty. */
+                        modified = TRUE;
                 }
             }
 
diff --git a/dlls/urlmon/uri.c b/dlls/urlmon/uri.c
index 44e37b1..9e20f2e 100644
--- a/dlls/urlmon/uri.c
+++ b/dlls/urlmon/uri.c
@@ -5082,6 +5082,11 @@ static HRESULT WINAPI UriBuilder_SetHost(IUriBuilder *iface, LPCWSTR pwzNewValue
 {
     UriBuilder *This = URIBUILDER_THIS(iface);
     TRACE("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
+
+    /* Host name can't be set to NULL. */
+    if(!pwzNewValue)
+        return E_INVALIDARG;
+
     return set_builder_component(&This->host, &This->host_len, pwzNewValue, 0,
                                  &This->modified_props, Uri_HAS_HOST);
 }
@@ -5127,11 +5132,11 @@ static HRESULT WINAPI UriBuilder_SetSchemeName(IUriBuilder *iface, LPCWSTR pwzNe
     TRACE("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
 
     /* Only set the scheme name if it's not NULL or empty. */
-    if(pwzNewValue && *pwzNewValue)
-        return set_builder_component(&This->scheme, &This->scheme_len, pwzNewValue, 0,
-                                     &This->modified_props, Uri_HAS_SCHEME_NAME);
-    else
+    if(!pwzNewValue || !*pwzNewValue)
         return E_INVALIDARG;
+
+    return set_builder_component(&This->scheme, &This->scheme_len, pwzNewValue, 0,
+                                 &This->modified_props, Uri_HAS_SCHEME_NAME);
 }
 
 static HRESULT WINAPI UriBuilder_SetUserName(IUriBuilder *iface, LPCWSTR pwzNewValue)
@@ -5157,8 +5162,12 @@ static HRESULT WINAPI UriBuilder_RemoveProperties(IUriBuilder *iface, DWORD dwPr
     if(dwPropertyMask & Uri_HAS_FRAGMENT)
         UriBuilder_SetFragment(iface, NULL);
 
+    /* Even though you can't set the host name to NULL or an
+     * empty string, you can still remove it... for some reason.
+     */
     if(dwPropertyMask & Uri_HAS_HOST)
-        UriBuilder_SetHost(iface, NULL);
+        set_builder_component(&This->host, &This->host_len, NULL, 0,
+                              &This->modified_props, Uri_HAS_HOST);
 
     if(dwPropertyMask & Uri_HAS_PASSWORD)
         UriBuilder_SetPassword(iface, NULL);




More information about the wine-cvs mailing list