From 448e939ebe3faeec2f837b1c44a14c58e8ba93c5 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 18 Mar 2013 12:44:44 +0400 Subject: [PATCH] msxml3: Embed user/password in uri used to create a moniker. --- dlls/msxml3/httprequest.c | 61 ++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/dlls/msxml3/httprequest.c b/dlls/msxml3/httprequest.c index c67177bcf45..681ccab8987 100644 --- a/dlls/msxml3/httprequest.c +++ b/dlls/msxml3/httprequest.c @@ -619,8 +619,27 @@ static HRESULT WINAPI Authenticate_Authenticate(IAuthenticate *iface, HWND *hwnd, LPWSTR *username, LPWSTR *password) { BindStatusCallback *This = impl_from_IAuthenticate(iface); - FIXME("(%p)->(%p %p %p)\n", This, hwnd, username, password); - return E_NOTIMPL; + httprequest *request = This->request; + + TRACE("(%p)->(%p %p %p)\n", This, hwnd, username, password); + + if (request->user && *request->user) + { + if (hwnd) *hwnd = NULL; + *username = CoTaskMemAlloc(SysStringByteLen(request->user)+sizeof(WCHAR)); + *password = CoTaskMemAlloc(SysStringByteLen(request->password)+sizeof(WCHAR)); + if (!*username || !*password) + { + CoTaskMemFree(*username); + CoTaskMemFree(*password); + return E_OUTOFMEMORY; + } + + memcpy(*username, request->user, SysStringByteLen(request->user)+sizeof(WCHAR)); + memcpy(*password, request->password, SysStringByteLen(request->password)+sizeof(WCHAR)); + } + + return S_OK; } static const IAuthenticateVtbl AuthenticateVtbl = { @@ -882,12 +901,6 @@ static HRESULT httprequest_open(httprequest *This, BSTR method, BSTR url, return hr; } - This->uri = uri; - - VariantInit(&is_async); - hr = VariantChangeType(&is_async, &async, 0, VT_BOOL); - This->async = hr == S_OK && V_BOOL(&is_async); - VariantInit(&str); hr = VariantChangeType(&str, &user, 0, VT_BSTR); if (hr == S_OK) @@ -898,6 +911,38 @@ static HRESULT httprequest_open(httprequest *This, BSTR method, BSTR url, if (hr == S_OK) This->password = V_BSTR(&str); + /* add authentication info */ + if (This->user && *This->user) + { + IUriBuilder *builder; + + hr = CreateIUriBuilder(uri, 0, 0, &builder); + if (hr == S_OK) + { + IUri *full_uri; + + IUriBuilder_SetUserName(builder, This->user); + IUriBuilder_SetPassword(builder, This->password); + hr = IUriBuilder_CreateUri(builder, -1, 0, 0, &full_uri); + if (hr == S_OK) + { + IUri_Release(uri); + uri = full_uri; + } + else + WARN("failed to create modified uri, 0x%08x\n", hr); + IUriBuilder_Release(builder); + } + else + WARN("IUriBuilder creation failed, 0x%08x\n", hr); + } + + This->uri = uri; + + VariantInit(&is_async); + hr = VariantChangeType(&is_async, &async, 0, VT_BOOL); + This->async = hr == S_OK && V_BOOL(&is_async); + httprequest_setreadystate(This, READYSTATE_LOADING); return S_OK;