urlmon: Implemented IUriBuilder_{Get/Set}Password.
authorThomas Mullaly <thomas.mullaly@gmail.com>
Sun, 5 Sep 2010 15:37:21 +0000 (11:37 -0400)
committerAlexandre Julliard <julliard@winehq.org>
Mon, 6 Sep 2010 15:07:39 +0000 (17:07 +0200)
dlls/urlmon/tests/uri.c
dlls/urlmon/uri.c

index 21c841ef89de10f4e005df7f98ffda35fe10f1fd..cfd7a04a96ce08fb10a5292f72e1f8f2657820a0 100644 (file)
@@ -4279,7 +4279,7 @@ static const uri_builder_test uri_builder_tests[] = {
     {   "http://google.com/",0,S_OK,FALSE,
         {
             {TRUE,"#fragment",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
-            {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,TRUE},
+            {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE},
             {TRUE,"?query=x",NULL,Uri_PROPERTY_QUERY,S_OK,TRUE},
             {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,TRUE}
         },
@@ -4440,6 +4440,70 @@ static const uri_builder_test uri_builder_tests[] = {
             {URL_SCHEME_HTTP,S_OK},
             {URLZONE_INVALID,E_NOTIMPL}
         }
+    },
+    {   "http://google.com/",0,S_OK,FALSE,
+        {
+            {TRUE,":password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
+        },
+        {FALSE},
+        0,S_OK,TRUE,
+        0,S_OK,TRUE,
+        0,0,0,S_OK,TRUE,
+        {
+            {"http://::password@google.com/",S_OK},
+            {"::password@google.com",S_OK},
+            {"http://google.com/",S_OK},
+            {"google.com",S_OK},
+            {"",S_FALSE},
+            {"",S_FALSE},
+            {"google.com",S_OK},
+            {":password",S_OK},
+            {"/",S_OK},
+            {"/",S_OK},
+            {"",S_FALSE},
+            {"http://::password@google.com/",S_OK},
+            {"http",S_OK},
+            {"::password",S_OK},
+            {"",S_FALSE}
+        },
+        {
+            {Uri_HOST_DNS,S_OK},
+            {80,S_OK},
+            {URL_SCHEME_HTTP,S_OK},
+            {URLZONE_INVALID,E_NOTIMPL}
+        }
+    },
+    {   "test/test",Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
+        {
+            {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
+        },
+        {FALSE},
+        Uri_CREATE_ALLOW_RELATIVE,S_OK,TRUE,
+        0,S_OK,TRUE,
+        Uri_CREATE_ALLOW_RELATIVE,0,0,S_OK,TRUE,
+        {
+            {":password@test/test",S_OK},
+            {":password@",S_OK},
+            {":password@test/test",S_OK},
+            {"",S_FALSE},
+            {"",S_FALSE},
+            {"",S_FALSE},
+            {"",S_FALSE},
+            {"password",S_OK},
+            {"test/test",S_OK},
+            {"test/test",S_OK},
+            {"",S_FALSE},
+            {":password@test/test",S_OK},
+            {"",S_FALSE},
+            {":password",S_OK},
+            {"",S_FALSE}
+        },
+        {
+            {Uri_HOST_UNKNOWN,S_OK},
+            {0,S_FALSE},
+            {URL_SCHEME_UNKNOWN,S_OK},
+            {URLZONE_INVALID,E_NOTIMPL}
+        }
     }
 };
 
index 195786c7e37fa8164f1c107e0824811610b3227e..b5e9df0f622547aaf1be1e78ebd97ce07dacd546 100644 (file)
@@ -85,6 +85,9 @@ typedef struct {
 
     WCHAR   *host;
     DWORD   host_len;
+
+    WCHAR   *password;
+    DWORD   password_len;
 } UriBuilder;
 
 typedef struct {
@@ -4314,6 +4317,7 @@ static ULONG WINAPI UriBuilder_Release(IUriBuilder *iface)
         if(This->uri) IUri_Release(URI(This->uri));
         heap_free(This->fragment);
         heap_free(This->host);
+        heap_free(This->password);
         heap_free(This);
     }
 
@@ -4462,19 +4466,13 @@ static HRESULT WINAPI UriBuilder_GetPassword(IUriBuilder *iface, DWORD *pcchPass
     UriBuilder *This = URIBUILDER_THIS(iface);
     TRACE("(%p)->(%p %p)\n", This, pcchPassword, ppwzPassword);
 
-    if(!pcchPassword) {
-        if(ppwzPassword)
-            *ppwzPassword = NULL;
-        return E_POINTER;
-    }
-
-    if(!ppwzPassword) {
-        *pcchPassword = 0;
-        return E_POINTER;
+    if(!This->uri || This->uri->userinfo_split == -1 || This->modified_props & Uri_HAS_PASSWORD)
+        return get_builder_component(&This->password, &This->password_len, NULL, 0, ppwzPassword, pcchPassword);
+    else {
+        const WCHAR *start = This->uri->canon_uri+This->uri->userinfo_start+This->uri->userinfo_split+1;
+        DWORD len = This->uri->userinfo_len-This->uri->userinfo_split-1;
+        return get_builder_component(&This->password, &This->password_len, start, len, ppwzPassword, pcchPassword);
     }
-
-    FIXME("(%p)->(%p %p)\n", This, pcchPassword, ppwzPassword);
-    return E_NOTIMPL;
 }
 
 static HRESULT WINAPI UriBuilder_GetPath(IUriBuilder *iface, DWORD *pcchPath, LPCWSTR *ppwzPath)
@@ -4598,8 +4596,10 @@ static HRESULT WINAPI UriBuilder_SetHost(IUriBuilder *iface, LPCWSTR pwzNewValue
 static HRESULT WINAPI UriBuilder_SetPassword(IUriBuilder *iface, LPCWSTR pwzNewValue)
 {
     UriBuilder *This = URIBUILDER_THIS(iface);
-    FIXME("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
-    return E_NOTIMPL;
+    TRACE("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
+
+    This->modified_props |= Uri_HAS_PASSWORD;
+    return set_builder_component(&This->password, &This->password_len, pwzNewValue, 0);
 }
 
 static HRESULT WINAPI UriBuilder_SetPath(IUriBuilder *iface, LPCWSTR pwzNewValue)