From 0a4e85418224667d32518e6cdc50f7c741889951 Mon Sep 17 00:00:00 2001 From: Thomas Mullaly Date: Sun, 5 Sep 2010 11:37:21 -0400 Subject: [PATCH] urlmon: Implemented IUriBuilder_{Get/Set}Password. --- dlls/urlmon/tests/uri.c | 66 ++++++++++++++++++++++++++++++++++++++++- dlls/urlmon/uri.c | 28 ++++++++--------- 2 files changed, 79 insertions(+), 15 deletions(-) diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c index 21c841ef89d..cfd7a04a96c 100644 --- a/dlls/urlmon/tests/uri.c +++ b/dlls/urlmon/tests/uri.c @@ -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} + } } }; diff --git a/dlls/urlmon/uri.c b/dlls/urlmon/uri.c index 195786c7e37..b5e9df0f622 100644 --- a/dlls/urlmon/uri.c +++ b/dlls/urlmon/uri.c @@ -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(!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); } - - if(!ppwzPassword) { - *pcchPassword = 0; - return E_POINTER; - } - - 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)