Commit 0da2e4c3 authored by Thomas Mullaly's avatar Thomas Mullaly Committed by Alexandre Julliard

urlmon: Can't set the scheme name of a IUriBuilder to NULL or an empty string.

parent f39d9452
...@@ -4922,6 +4922,72 @@ static const uri_builder_test uri_builder_tests[] = { ...@@ -4922,6 +4922,72 @@ static const uri_builder_test uri_builder_tests[] = {
{URL_SCHEME_HTTP,S_OK}, {URL_SCHEME_HTTP,S_OK},
{URLZONE_INVALID,E_NOTIMPL} {URLZONE_INVALID,E_NOTIMPL}
} }
},
/* Can't set the scheme name to NULL. */
{ "zip://google.com/",0,S_OK,FALSE,
{
{TRUE,NULL,"zip",Uri_PROPERTY_SCHEME_NAME,E_INVALIDARG,FALSE}
},
{FALSE},
0,S_OK,TRUE,
0,S_OK,TRUE,
0,0,0,S_OK,TRUE,
{
{"zip://google.com/",S_OK},
{"google.com",S_OK},
{"zip://google.com/",S_OK},
{"google.com",S_OK},
{"",S_FALSE},
{"",S_FALSE},
{"google.com",S_OK},
{"",S_FALSE},
{"/",S_OK},
{"/",S_OK},
{"",S_FALSE},
{"zip://google.com/",S_OK},
{"zip",S_OK},
{"",S_FALSE},
{"",S_FALSE}
},
{
{Uri_HOST_DNS,S_OK},
{0,S_FALSE},
{URL_SCHEME_UNKNOWN,S_OK},
{URLZONE_INVALID,E_NOTIMPL}
}
},
/* Can't set the scheme name to an empty string. */
{ "zip://google.com/",0,S_OK,FALSE,
{
{TRUE,"","zip",Uri_PROPERTY_SCHEME_NAME,E_INVALIDARG,FALSE}
},
{FALSE},
0,S_OK,TRUE,
0,S_OK,TRUE,
0,0,0,S_OK,TRUE,
{
{"zip://google.com/",S_OK},
{"google.com",S_OK},
{"zip://google.com/",S_OK},
{"google.com",S_OK},
{"",S_FALSE},
{"",S_FALSE},
{"google.com",S_OK},
{"",S_FALSE},
{"/",S_OK},
{"/",S_OK},
{"",S_FALSE},
{"zip://google.com/",S_OK},
{"zip",S_OK},
{"",S_FALSE},
{"",S_FALSE}
},
{
{Uri_HOST_DNS,S_OK},
{0,S_FALSE},
{URL_SCHEME_UNKNOWN,S_OK},
{URLZONE_INVALID,E_NOTIMPL}
}
} }
}; };
...@@ -4975,6 +5041,11 @@ static const uri_builder_remove_test uri_builder_remove_tests[] = { ...@@ -4975,6 +5041,11 @@ static const uri_builder_remove_test uri_builder_remove_tests[] = {
{ "http://google.com/?test=x",0,S_OK,FALSE, { "http://google.com/?test=x",0,S_OK,FALSE,
Uri_HAS_PATH_AND_QUERY,S_OK,FALSE, Uri_HAS_PATH_AND_QUERY,S_OK,FALSE,
"http://google.com/?test=x",0,S_OK,TRUE "http://google.com/?test=x",0,S_OK,TRUE
},
/* Can't remove the scheme name. */
{ "http://google.com/?test=x",0,S_OK,FALSE,
Uri_HAS_SCHEME_NAME|Uri_HAS_QUERY,E_INVALIDARG,FALSE,
"http://google.com/?test=x",0,S_OK,TRUE
} }
}; };
...@@ -7519,7 +7590,7 @@ static void test_IUriBuilder_GetUserName(IUriBuilder *builder, const uri_builder ...@@ -7519,7 +7590,7 @@ static void test_IUriBuilder_GetUserName(IUriBuilder *builder, const uri_builder
prop = &(test->properties[i]); prop = &(test->properties[i]);
} }
if(prop) { if(prop && prop->value && *prop->value) {
/* Use expected_value unless it's NULL, then use value. */ /* Use expected_value unless it's NULL, then use value. */
LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value; LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
hr = IUriBuilder_GetUserName(builder, &len, &received); hr = IUriBuilder_GetUserName(builder, &len, &received);
...@@ -7652,8 +7723,11 @@ static void test_IUriBuilder(void) { ...@@ -7652,8 +7723,11 @@ static void test_IUriBuilder(void) {
for(j = 0; j < URI_BUILDER_STR_PROPERTY_COUNT; ++j) { for(j = 0; j < URI_BUILDER_STR_PROPERTY_COUNT; ++j) {
uri_builder_property prop = test.properties[j]; uri_builder_property prop = test.properties[j];
if(prop.change) { if(prop.change) {
modified = TRUE;
change_property(builder, &prop, i); change_property(builder, &prop, i);
if(prop.property != Uri_PROPERTY_SCHEME_NAME)
modified = TRUE;
else if(prop.value && *prop.value)
modified = TRUE;
} }
} }
......
...@@ -4729,8 +4729,13 @@ static HRESULT WINAPI UriBuilder_SetSchemeName(IUriBuilder *iface, LPCWSTR pwzNe ...@@ -4729,8 +4729,13 @@ static HRESULT WINAPI UriBuilder_SetSchemeName(IUriBuilder *iface, LPCWSTR pwzNe
{ {
UriBuilder *This = URIBUILDER_THIS(iface); UriBuilder *This = URIBUILDER_THIS(iface);
TRACE("(%p)->(%s)\n", This, debugstr_w(pwzNewValue)); TRACE("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
/* Only set the scheme name if it's not NULL or empty. */
if(pwzNewValue && *pwzNewValue)
return set_builder_component(&This->scheme, &This->scheme_len, pwzNewValue, 0, return set_builder_component(&This->scheme, &This->scheme_len, pwzNewValue, 0,
&This->modified_props, Uri_HAS_SCHEME_NAME); &This->modified_props, Uri_HAS_SCHEME_NAME);
else
return E_INVALIDARG;
} }
static HRESULT WINAPI UriBuilder_SetUserName(IUriBuilder *iface, LPCWSTR pwzNewValue) static HRESULT WINAPI UriBuilder_SetUserName(IUriBuilder *iface, LPCWSTR pwzNewValue)
...@@ -4745,7 +4750,7 @@ static HRESULT WINAPI UriBuilder_RemoveProperties(IUriBuilder *iface, DWORD dwPr ...@@ -4745,7 +4750,7 @@ static HRESULT WINAPI UriBuilder_RemoveProperties(IUriBuilder *iface, DWORD dwPr
{ {
const DWORD accepted_flags = Uri_HAS_AUTHORITY|Uri_HAS_DOMAIN|Uri_HAS_EXTENSION|Uri_HAS_FRAGMENT|Uri_HAS_HOST| const DWORD accepted_flags = Uri_HAS_AUTHORITY|Uri_HAS_DOMAIN|Uri_HAS_EXTENSION|Uri_HAS_FRAGMENT|Uri_HAS_HOST|
Uri_HAS_PASSWORD|Uri_HAS_PATH|Uri_HAS_PATH_AND_QUERY|Uri_HAS_QUERY| Uri_HAS_PASSWORD|Uri_HAS_PATH|Uri_HAS_PATH_AND_QUERY|Uri_HAS_QUERY|
Uri_HAS_SCHEME_NAME|Uri_HAS_USER_INFO|Uri_HAS_USER_NAME; Uri_HAS_USER_INFO|Uri_HAS_USER_NAME;
UriBuilder *This = URIBUILDER_THIS(iface); UriBuilder *This = URIBUILDER_THIS(iface);
TRACE("(%p)->(0x%08x)\n", This, dwPropertyMask); TRACE("(%p)->(0x%08x)\n", This, dwPropertyMask);
...@@ -4771,9 +4776,6 @@ static HRESULT WINAPI UriBuilder_RemoveProperties(IUriBuilder *iface, DWORD dwPr ...@@ -4771,9 +4776,6 @@ static HRESULT WINAPI UriBuilder_RemoveProperties(IUriBuilder *iface, DWORD dwPr
if(dwPropertyMask & Uri_HAS_QUERY) if(dwPropertyMask & Uri_HAS_QUERY)
UriBuilder_SetQuery(iface, NULL); UriBuilder_SetQuery(iface, NULL);
if(dwPropertyMask & Uri_HAS_SCHEME_NAME)
UriBuilder_SetSchemeName(iface, NULL);
if(dwPropertyMask & Uri_HAS_USER_NAME) if(dwPropertyMask & Uri_HAS_USER_NAME)
UriBuilder_SetUserName(iface, NULL); UriBuilder_SetUserName(iface, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment