Commit bd7c86bb authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

webservices: Also trace return values in the URL functions.

parent 8bd48fd6
......@@ -192,22 +192,22 @@ HRESULT WINAPI WsDecodeUrl( const WS_STRING *str, ULONG flags, WS_HEAP *heap, WS
return E_NOTIMPL;
}
if (!(decoded = url_decode( str->chars, str->length, heap, &len_decoded )) ||
!(url = ws_alloc( heap, sizeof(*url) ))) goto error;
!(url = ws_alloc( heap, sizeof(*url) ))) goto done;
hr = WS_E_INVALID_FORMAT;
p = q = decoded;
len = len_decoded;
while (len && *q != ':') { q++; len--; };
if (*q != ':') goto error;
if ((url->url.scheme = scheme_type( p, q - p )) == ~0u) goto error;
if (*q != ':') goto done;
if ((url->url.scheme = scheme_type( p, q - p )) == ~0u) goto done;
if (!--len || *++q != '/') goto error;
if (!--len || *++q != '/') goto error;
if (!--len || *++q != '/') goto done;
if (!--len || *++q != '/') goto done;
p = ++q; len--;
while (len && *q != '/' && *q != ':' && *q != '?' && *q != '#') { q++; len--; };
if (q == p) goto error;
if (q == p) goto done;
url->host.length = q - p;
url->host.chars = p;
......@@ -216,7 +216,7 @@ HRESULT WINAPI WsDecodeUrl( const WS_STRING *str, ULONG flags, WS_HEAP *heap, WS
p = ++q; len--;
while (len && isdigitW( *q ))
{
if ((port = port * 10 + *q - '0') > 65535) goto error;
if ((port = port * 10 + *q - '0') > 65535) goto done;
q++; len--;
};
url->port = port;
......@@ -258,11 +258,15 @@ HRESULT WINAPI WsDecodeUrl( const WS_STRING *str, ULONG flags, WS_HEAP *heap, WS
else url->fragment.length = 0;
*ret = (WS_URL *)url;
return S_OK;
hr = S_OK;
error:
if (decoded != str->chars) ws_free( heap, decoded, len_decoded );
ws_free( heap, url, sizeof(*url) );
done:
if (hr != S_OK)
{
if (decoded != str->chars) ws_free( heap, decoded, len_decoded );
ws_free( heap, url, sizeof(*url) );
}
TRACE( "returning %08x\n", hr );
return hr;
}
......@@ -420,12 +424,12 @@ HRESULT WINAPI WsEncodeUrl( const WS_URL *base, ULONG flags, WS_HEAP *heap, WS_S
WS_ERROR *error )
{
static const WCHAR fmtW[] = {':','%','u',0};
ULONG len = 0, len_scheme, len_enc, ret_size;
ULONG len = 0, len_scheme, len_enc, ret_size = 0;
const WS_HTTP_URL *url = (const WS_HTTP_URL *)base;
const WCHAR *scheme;
WCHAR *str, *p, *q;
WCHAR *str = NULL, *p, *q;
ULONG port = 0;
HRESULT hr;
HRESULT hr = WS_E_INVALID_FORMAT;
TRACE( "%p %08x %p %p %p\n", base, flags, heap, ret, error );
if (error) FIXME( "ignoring error parameter\n" );
......@@ -436,28 +440,32 @@ HRESULT WINAPI WsEncodeUrl( const WS_URL *base, ULONG flags, WS_HEAP *heap, WS_S
FIXME( "unimplemented flags %08x\n", flags );
return E_NOTIMPL;
}
if (!(scheme = scheme_str( url->url.scheme, &len_scheme ))) return WS_E_INVALID_FORMAT;
if (!(scheme = scheme_str( url->url.scheme, &len_scheme ))) goto done;
len = len_scheme + 3; /* '://' */
len += 6; /* ':65535' */
if ((hr = url_encode_size( url->host.chars, url->host.length, "", &len_enc )) != S_OK)
return hr;
goto done;
len += len_enc;
if ((hr = url_encode_size( url->path.chars, url->path.length, "/", &len_enc )) != S_OK)
return hr;
goto done;
len += len_enc;
if ((hr = url_encode_size( url->query.chars, url->query.length, "/?", &len_enc )) != S_OK)
return hr;
goto done;
len += len_enc + 1; /* '?' */
if ((hr = url_encode_size( url->fragment.chars, url->fragment.length, "/?", &len_enc )) != S_OK)
return hr;
goto done;
len += len_enc + 1; /* '#' */
ret_size = len * sizeof(WCHAR);
if (!(str = ws_alloc( heap, ret_size ))) return WS_E_QUOTA_EXCEEDED;
if (!(str = ws_alloc( heap, ret_size )))
{
hr = WS_E_QUOTA_EXCEEDED;
goto done;
}
memcpy( str, scheme, len_scheme * sizeof(WCHAR) );
p = str + len_scheme;
......@@ -466,7 +474,7 @@ HRESULT WINAPI WsEncodeUrl( const WS_URL *base, ULONG flags, WS_HEAP *heap, WS_S
p += 3;
if ((hr = url_encode( url->host.chars, url->host.length, p, "", &len_enc )) != S_OK)
goto error;
goto done;
p += len_enc;
if (url->portAsString.length)
......@@ -478,14 +486,14 @@ HRESULT WINAPI WsEncodeUrl( const WS_URL *base, ULONG flags, WS_HEAP *heap, WS_S
if ((port = port * 10 + *q - '0') > 65535)
{
hr = WS_E_INVALID_FORMAT;
goto error;
goto done;
}
q++; len--;
}
if (url->port && port != url->port)
{
hr = E_INVALIDARG;
goto error;
goto done;
}
} else port = url->port;
......@@ -499,14 +507,14 @@ HRESULT WINAPI WsEncodeUrl( const WS_URL *base, ULONG flags, WS_HEAP *heap, WS_S
}
if ((hr = url_encode( url->path.chars, url->path.length, p, "/", &len_enc )) != S_OK)
goto error;
goto done;
p += len_enc;
if (url->query.length)
{
*p++ = '?';
if ((hr = url_encode( url->query.chars, url->query.length, p, "/?", &len_enc )) != S_OK)
goto error;
goto done;
p += len_enc;
}
......@@ -514,15 +522,16 @@ HRESULT WINAPI WsEncodeUrl( const WS_URL *base, ULONG flags, WS_HEAP *heap, WS_S
{
*p++ = '#';
if ((hr = url_encode( url->fragment.chars, url->fragment.length, p, "/?", &len_enc )) != S_OK)
goto error;
goto done;
p += len_enc;
}
ret->length = p - str;
ret->chars = str;
return S_OK;
hr = S_OK;
error:
ws_free( heap, str, ret_size );
done:
if (hr != S_OK) ws_free( heap, str, ret_size );
TRACE( "returning %08x\n", hr );
return hr;
}
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