Commit 8fe7be58 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

wininet: Added IsDomainLegalCookieDomainW helper with substrings as arguments.

parent 4f39a2db
...@@ -867,40 +867,25 @@ BOOL WINAPI InternetGetCookieExA(LPCSTR lpszUrl, LPCSTR lpszCookieName, ...@@ -867,40 +867,25 @@ BOOL WINAPI InternetGetCookieExA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
*/ */
BOOL WINAPI InternetGetCookieA(const char *url, const char *name, char *data, DWORD *size) BOOL WINAPI InternetGetCookieA(const char *url, const char *name, char *data, DWORD *size)
{ {
TRACE("(%s, %s, %s, %p)\n", debugstr_a(url), debugstr_a(name), debugstr_a(data), size); TRACE("(%s, %s, %p, %p)\n", debugstr_a(url), debugstr_a(name), data, size);
return InternetGetCookieExA(url, name, data, size, 0, NULL); return InternetGetCookieExA(url, name, data, size, 0, NULL);
} }
/*********************************************************************** static BOOL is_domain_legal_for_cookie(substr_t domain, substr_t full_domain)
* IsDomainLegalCookieDomainW (WININET.@)
*/
BOOL WINAPI IsDomainLegalCookieDomainW( LPCWSTR s1, LPCWSTR s2 )
{ {
DWORD s1_len, s2_len; const WCHAR *ptr;
FIXME("(%s, %s) semi-stub\n", debugstr_w(s1), debugstr_w(s2)); if(!domain.len || *domain.str == '.' || !full_domain.len || *full_domain.str == '.') {
if (!s1 || !s2)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if (s1[0] == '.' || !s1[0] || s2[0] == '.' || !s2[0])
{
SetLastError(ERROR_INVALID_NAME); SetLastError(ERROR_INVALID_NAME);
return FALSE; return FALSE;
} }
if(!strchrW(s1, '.') || !strchrW(s2, '.'))
return FALSE;
s1_len = strlenW(s1); if(domain.len > full_domain.len || !memchrW(domain.str, '.', domain.len) || !memchrW(full_domain.str, '.', full_domain.len))
s2_len = strlenW(s2);
if (s1_len > s2_len)
return FALSE; return FALSE;
if (strncmpiW(s1, s2+s2_len-s1_len, s1_len) || (s2_len>s1_len && s2[s2_len-s1_len-1]!='.')) ptr = full_domain.str + full_domain.len - domain.len;
{ if (strncmpiW(domain.str, ptr, domain.len) || (full_domain.len > domain.len && ptr[-1] != '.')) {
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
return FALSE; return FALSE;
} }
...@@ -908,6 +893,21 @@ BOOL WINAPI IsDomainLegalCookieDomainW( LPCWSTR s1, LPCWSTR s2 ) ...@@ -908,6 +893,21 @@ BOOL WINAPI IsDomainLegalCookieDomainW( LPCWSTR s1, LPCWSTR s2 )
return TRUE; return TRUE;
} }
/***********************************************************************
* IsDomainLegalCookieDomainW (WININET.@)
*/
BOOL WINAPI IsDomainLegalCookieDomainW(const WCHAR *domain, const WCHAR *full_domain)
{
FIXME("(%s, %s) semi-stub\n", debugstr_w(domain), debugstr_w(full_domain));
if (!domain || !full_domain) {
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
return is_domain_legal_for_cookie(substrz(domain), substrz(full_domain));
}
DWORD set_cookie(const WCHAR *domain, const WCHAR *path, const WCHAR *cookie_name, const WCHAR *cookie_data, DWORD flags) DWORD set_cookie(const WCHAR *domain, const WCHAR *path, const WCHAR *cookie_name, const WCHAR *cookie_data, DWORD flags)
{ {
cookie_container_t *container; cookie_container_t *container;
......
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