urlmon: Can't set the host of a IUriBuilder to NULL.

This commit is contained in:
Thomas Mullaly 2010-09-22 17:32:46 -04:00 committed by Alexandre Julliard
parent cbea4e2a85
commit 7e292893bd
2 changed files with 85 additions and 6 deletions

View File

@ -5295,6 +5295,72 @@ static const uri_builder_test uri_builder_tests[] = {
{URL_SCHEME_HTTP,S_OK},
{URLZONE_INVALID,E_NOTIMPL}
}
},
/* Can't set the host name to NULL. */
{ "http://google.com/",0,S_OK,FALSE,
{
{TRUE,NULL,"google.com",Uri_PROPERTY_HOST,E_INVALIDARG,FALSE}
},
{FALSE},
0,S_OK,FALSE,
0,S_OK,FALSE,
0,0,0,S_OK,FALSE,
{
{"http://google.com/",S_OK},
{"google.com",S_OK},
{"http://google.com/",S_OK},
{"google.com",S_OK},
{"",S_FALSE},
{"",S_FALSE},
{"google.com",S_OK},
{"",S_FALSE},
{"/",S_OK},
{"/",S_OK},
{"",S_FALSE},
{"http://google.com/",S_OK},
{"http",S_OK},
{"",S_FALSE},
{"",S_FALSE}
},
{
{Uri_HOST_DNS,S_OK},
{80,S_OK},
{URL_SCHEME_HTTP,S_OK},
{URLZONE_INVALID,E_NOTIMPL}
}
},
/* Can set the host name to an empty string. */
{ "http://google.com/",0,S_OK,FALSE,
{
{TRUE,"",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
},
{FALSE},
0,S_OK,TRUE,
0,S_OK,TRUE,
0,0,0,S_OK,TRUE,
{
{"http:///",S_OK},
{"",S_OK},
{"http:///",S_OK},
{"",S_FALSE},
{"",S_FALSE},
{"",S_FALSE},
{"",S_OK},
{"",S_FALSE},
{"/",S_OK},
{"/",S_OK},
{"",S_FALSE},
{"http:///",S_OK},
{"http",S_OK},
{"",S_FALSE},
{"",S_FALSE}
},
{
{Uri_HOST_UNKNOWN,S_OK},
{80,S_OK},
{URL_SCHEME_HTTP,S_OK},
{URLZONE_INVALID,E_NOTIMPL}
}
}
};
@ -8025,10 +8091,14 @@ static void test_IUriBuilder(void) {
uri_builder_property prop = test.properties[j];
if(prop.change) {
change_property(builder, &prop, i);
if(prop.property != Uri_PROPERTY_SCHEME_NAME)
if(prop.property != Uri_PROPERTY_SCHEME_NAME &&
prop.property != Uri_PROPERTY_HOST)
modified = TRUE;
else if(prop.value && *prop.value)
modified = TRUE;
else if(prop.value && !*prop.value && prop.property == Uri_PROPERTY_HOST)
/* Host name property can't be NULL, but it can be empty. */
modified = TRUE;
}
}

View File

@ -5082,6 +5082,11 @@ static HRESULT WINAPI UriBuilder_SetHost(IUriBuilder *iface, LPCWSTR pwzNewValue
{
UriBuilder *This = URIBUILDER_THIS(iface);
TRACE("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
/* Host name can't be set to NULL. */
if(!pwzNewValue)
return E_INVALIDARG;
return set_builder_component(&This->host, &This->host_len, pwzNewValue, 0,
&This->modified_props, Uri_HAS_HOST);
}
@ -5127,11 +5132,11 @@ static HRESULT WINAPI UriBuilder_SetSchemeName(IUriBuilder *iface, LPCWSTR pwzNe
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,
&This->modified_props, Uri_HAS_SCHEME_NAME);
else
if(!pwzNewValue || !*pwzNewValue)
return E_INVALIDARG;
return set_builder_component(&This->scheme, &This->scheme_len, pwzNewValue, 0,
&This->modified_props, Uri_HAS_SCHEME_NAME);
}
static HRESULT WINAPI UriBuilder_SetUserName(IUriBuilder *iface, LPCWSTR pwzNewValue)
@ -5157,8 +5162,12 @@ static HRESULT WINAPI UriBuilder_RemoveProperties(IUriBuilder *iface, DWORD dwPr
if(dwPropertyMask & Uri_HAS_FRAGMENT)
UriBuilder_SetFragment(iface, NULL);
/* Even though you can't set the host name to NULL or an
* empty string, you can still remove it... for some reason.
*/
if(dwPropertyMask & Uri_HAS_HOST)
UriBuilder_SetHost(iface, NULL);
set_builder_component(&This->host, &This->host_len, NULL, 0,
&This->modified_props, Uri_HAS_HOST);
if(dwPropertyMask & Uri_HAS_PASSWORD)
UriBuilder_SetPassword(iface, NULL);