From 380fd731e2d8bc6fb1e404539541a43b191fe575 Mon Sep 17 00:00:00 2001 From: Thomas Mullaly Date: Mon, 6 Sep 2010 17:55:23 -0400 Subject: [PATCH] urlmon: Implemented IUriBuilder_{Get/Set}UserName. --- dlls/urlmon/tests/uri.c | 34 +++++++++++++++++++++++++++++++++- dlls/urlmon/uri.c | 34 +++++++++++++++++++++------------- 2 files changed, 54 insertions(+), 14 deletions(-) diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c index 4c8f3584ac..85170461e6 100644 --- a/dlls/urlmon/tests/uri.c +++ b/dlls/urlmon/tests/uri.c @@ -4433,7 +4433,7 @@ static const uri_builder_test uri_builder_tests[] = { {TRUE,"#fragment",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}, {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}, {TRUE,"?query=x",NULL,Uri_PROPERTY_QUERY,S_OK,FALSE}, - {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,TRUE} + {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE} }, {FALSE}, 0,S_OK,TRUE, @@ -4856,6 +4856,38 @@ static const uri_builder_test uri_builder_tests[] = { {URL_SCHEME_HTTP,S_OK}, {URLZONE_INVALID,E_NOTIMPL} } + }, + { "http://:password@google.com/",0,S_OK,FALSE, + { + {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} + } } }; diff --git a/dlls/urlmon/uri.c b/dlls/urlmon/uri.c index 283c6499a7..94be29b145 100644 --- a/dlls/urlmon/uri.c +++ b/dlls/urlmon/uri.c @@ -100,6 +100,9 @@ typedef struct { WCHAR *scheme; DWORD scheme_len; + + WCHAR *username; + DWORD username_len; } UriBuilder; typedef struct { @@ -4383,6 +4386,7 @@ static ULONG WINAPI UriBuilder_Release(IUriBuilder *iface) heap_free(This->path); heap_free(This->query); heap_free(This->scheme); + heap_free(This->username); heap_free(This); } @@ -4602,19 +4606,22 @@ static HRESULT WINAPI UriBuilder_GetUserName(IUriBuilder *iface, DWORD *pcchUser UriBuilder *This = URIBUILDER_THIS(iface); TRACE("(%p)->(%p %p)\n", This, pcchUserName, ppwzUserName); - if(!pcchUserName) { - if(ppwzUserName) - *ppwzUserName = NULL; - return E_POINTER; - } + if(!This->uri || This->uri->userinfo_start == -1 || + This->uri->userinfo_start == This->uri->userinfo_split || + This->modified_props & Uri_HAS_USER_NAME) + return get_builder_component(&This->username, &This->username_len, NULL, 0, ppwzUserName, pcchUserName); + else { + const WCHAR *start = This->uri->canon_uri+This->uri->userinfo_start; - if(!ppwzUserName) { - *pcchUserName = 0; - return E_POINTER; + /* Check if there's a password in the userinfo section. */ + if(This->uri->userinfo_split > -1) + /* Don't include the password. */ + return get_builder_component(&This->username, &This->username_len, start, + This->uri->userinfo_split, ppwzUserName, pcchUserName); + else + return get_builder_component(&This->username, &This->username_len, start, + This->uri->userinfo_len, ppwzUserName, pcchUserName); } - - FIXME("(%p)->(%p %p)\n", This, pcchUserName, ppwzUserName); - return E_NOTIMPL; } static HRESULT WINAPI UriBuilder_SetFragment(IUriBuilder *iface, LPCWSTR pwzNewValue) @@ -4679,8 +4686,9 @@ static HRESULT WINAPI UriBuilder_SetSchemeName(IUriBuilder *iface, LPCWSTR pwzNe static HRESULT WINAPI UriBuilder_SetUserName(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)); + return set_builder_component(&This->username, &This->username_len, pwzNewValue, 0, + &This->modified_props, Uri_HAS_USER_NAME); } static HRESULT WINAPI UriBuilder_RemoveProperties(IUriBuilder *iface, DWORD dwPropertyMask) -- 2.32.0.93.g670b81a890