urlmon: Implemented CreateUriWithFragment.
This commit is contained in:
parent
39001c30d3
commit
6e4ead77a7
@ -3715,21 +3715,21 @@ typedef struct _uri_with_fragment {
|
|||||||
|
|
||||||
static const uri_with_fragment uri_fragment_tests[] = {
|
static const uri_with_fragment uri_fragment_tests[] = {
|
||||||
{
|
{
|
||||||
"http://google.com/","#fragment",0,S_OK,TRUE,
|
"http://google.com/","#fragment",0,S_OK,FALSE,
|
||||||
"http://google.com/#fragment",TRUE
|
"http://google.com/#fragment",FALSE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"http://google.com/","fragment",0,S_OK,TRUE,
|
"http://google.com/","fragment",0,S_OK,FALSE,
|
||||||
"http://google.com/#fragment",TRUE
|
"http://google.com/#fragment",FALSE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"zip://test.com/","?test",0,S_OK,TRUE,
|
"zip://test.com/","?test",0,S_OK,FALSE,
|
||||||
"zip://test.com/#?test",TRUE
|
"zip://test.com/#?test",FALSE
|
||||||
},
|
},
|
||||||
/* The fragment can be empty. */
|
/* The fragment can be empty. */
|
||||||
{
|
{
|
||||||
"ftp://ftp.google.com/","",0,S_OK,TRUE,
|
"ftp://ftp.google.com/","",0,S_OK,FALSE,
|
||||||
"ftp://ftp.google.com/#",TRUE
|
"ftp://ftp.google.com/#",FALSE
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -4802,23 +4802,17 @@ static void test_CreateUriWithFragment_InvalidArgs(void) {
|
|||||||
const WCHAR fragmentW[] = {'#','f','r','a','g','m','e','n','t',0};
|
const WCHAR fragmentW[] = {'#','f','r','a','g','m','e','n','t',0};
|
||||||
|
|
||||||
hr = pCreateUriWithFragment(NULL, fragmentW, 0, 0, &uri);
|
hr = pCreateUriWithFragment(NULL, fragmentW, 0, 0, &uri);
|
||||||
todo_wine {
|
|
||||||
ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
|
ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
|
||||||
}
|
ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
|
||||||
todo_wine { ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri); }
|
|
||||||
|
|
||||||
hr = pCreateUriWithFragment(http_urlW, fragmentW, 0, 0, NULL);
|
hr = pCreateUriWithFragment(http_urlW, fragmentW, 0, 0, NULL);
|
||||||
todo_wine {
|
|
||||||
ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
|
ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
|
||||||
}
|
|
||||||
|
|
||||||
/* Original URI can't already contain a fragment component. */
|
/* Original URI can't already contain a fragment component. */
|
||||||
uri = (void*) 0xdeadbeef;
|
uri = (void*) 0xdeadbeef;
|
||||||
hr = pCreateUriWithFragment(http_url_fragW, fragmentW, 0, 0, &uri);
|
hr = pCreateUriWithFragment(http_url_fragW, fragmentW, 0, 0, &uri);
|
||||||
todo_wine {
|
|
||||||
ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
|
ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
|
||||||
}
|
ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
|
||||||
todo_wine { ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CreateUriWithFragment has the same invalid flag combinations as CreateUri. */
|
/* CreateUriWithFragment has the same invalid flag combinations as CreateUri. */
|
||||||
@ -4830,11 +4824,9 @@ static void test_CreateUriWithFragment_InvalidFlags(void) {
|
|||||||
IUri *uri = (void*) 0xdeadbeef;
|
IUri *uri = (void*) 0xdeadbeef;
|
||||||
|
|
||||||
hr = pCreateUriWithFragment(http_urlW, NULL, invalid_flag_tests[i].flags, 0, &uri);
|
hr = pCreateUriWithFragment(http_urlW, NULL, invalid_flag_tests[i].flags, 0, &uri);
|
||||||
todo_wine {
|
|
||||||
ok(hr == invalid_flag_tests[i].expected, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x. flags=0x%08x.\n",
|
ok(hr == invalid_flag_tests[i].expected, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x. flags=0x%08x.\n",
|
||||||
hr, invalid_flag_tests[i].expected, invalid_flag_tests[i].flags);
|
hr, invalid_flag_tests[i].expected, invalid_flag_tests[i].flags);
|
||||||
}
|
ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
|
||||||
todo_wine { ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri); }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3952,8 +3952,56 @@ HRESULT WINAPI CreateUri(LPCWSTR pwzURI, DWORD dwFlags, DWORD_PTR dwReserved, IU
|
|||||||
HRESULT WINAPI CreateUriWithFragment(LPCWSTR pwzURI, LPCWSTR pwzFragment, DWORD dwFlags,
|
HRESULT WINAPI CreateUriWithFragment(LPCWSTR pwzURI, LPCWSTR pwzFragment, DWORD dwFlags,
|
||||||
DWORD_PTR dwReserved, IUri **ppURI)
|
DWORD_PTR dwReserved, IUri **ppURI)
|
||||||
{
|
{
|
||||||
FIXME("(%s %s %x %x %p)\n", debugstr_w(pwzURI), debugstr_w(pwzFragment), dwFlags, (DWORD)dwReserved, ppURI);
|
HRESULT hres;
|
||||||
return E_NOTIMPL;
|
TRACE("(%s %s %x %x %p)\n", debugstr_w(pwzURI), debugstr_w(pwzFragment), dwFlags, (DWORD)dwReserved, ppURI);
|
||||||
|
|
||||||
|
if(!ppURI)
|
||||||
|
return E_INVALIDARG;
|
||||||
|
|
||||||
|
if(!pwzURI) {
|
||||||
|
*ppURI = NULL;
|
||||||
|
return E_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if a fragment should be appended to the URI string. */
|
||||||
|
if(pwzFragment) {
|
||||||
|
WCHAR *uriW;
|
||||||
|
DWORD uri_len, frag_len;
|
||||||
|
BOOL add_pound;
|
||||||
|
|
||||||
|
/* Check if the original URI already has a fragment component. */
|
||||||
|
if(StrChrW(pwzURI, '#')) {
|
||||||
|
*ppURI = NULL;
|
||||||
|
return E_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
uri_len = lstrlenW(pwzURI);
|
||||||
|
frag_len = lstrlenW(pwzFragment);
|
||||||
|
|
||||||
|
/* If the fragment doesn't start with a '#', one will be added. */
|
||||||
|
add_pound = *pwzFragment != '#';
|
||||||
|
|
||||||
|
if(add_pound)
|
||||||
|
uriW = heap_alloc((uri_len+frag_len+2)*sizeof(WCHAR));
|
||||||
|
else
|
||||||
|
uriW = heap_alloc((uri_len+frag_len+1)*sizeof(WCHAR));
|
||||||
|
|
||||||
|
if(!uriW)
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
memcpy(uriW, pwzURI, uri_len*sizeof(WCHAR));
|
||||||
|
if(add_pound)
|
||||||
|
uriW[uri_len++] = '#';
|
||||||
|
memcpy(uriW+uri_len, pwzFragment, (frag_len+1)*sizeof(WCHAR));
|
||||||
|
|
||||||
|
hres = CreateUri(uriW, dwFlags, 0, ppURI);
|
||||||
|
|
||||||
|
heap_free(uriW);
|
||||||
|
} else
|
||||||
|
/* A fragment string wasn't specified, so just forward the call. */
|
||||||
|
hres = CreateUri(pwzURI, dwFlags, 0, ppURI);
|
||||||
|
|
||||||
|
return hres;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define URIBUILDER_THIS(iface) DEFINE_THIS(UriBuilder, IUriBuilder, iface)
|
#define URIBUILDER_THIS(iface) DEFINE_THIS(UriBuilder, IUriBuilder, iface)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user