Unicodify the cookie handling code.
This commit is contained in:
parent
1baf39f95a
commit
44ef9a1f07
|
@ -60,8 +60,8 @@ struct _cookie
|
||||||
|
|
||||||
struct _cookie_domain *parent;
|
struct _cookie_domain *parent;
|
||||||
|
|
||||||
LPSTR lpCookieName;
|
LPWSTR lpCookieName;
|
||||||
LPSTR lpCookieData;
|
LPWSTR lpCookieData;
|
||||||
time_t expiry; /* FIXME: not used */
|
time_t expiry; /* FIXME: not used */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -70,27 +70,27 @@ struct _cookie_domain
|
||||||
struct _cookie_domain *next;
|
struct _cookie_domain *next;
|
||||||
struct _cookie_domain *prev;
|
struct _cookie_domain *prev;
|
||||||
|
|
||||||
LPSTR lpCookieDomain;
|
LPWSTR lpCookieDomain;
|
||||||
LPSTR lpCookiePath;
|
LPWSTR lpCookiePath;
|
||||||
cookie *cookie_tail;
|
cookie *cookie_tail;
|
||||||
};
|
};
|
||||||
|
|
||||||
static cookie_domain *cookieDomainTail;
|
static cookie_domain *cookieDomainTail;
|
||||||
|
|
||||||
static cookie *COOKIE_addCookie(cookie_domain *domain, LPCSTR name, LPCSTR data);
|
static cookie *COOKIE_addCookie(cookie_domain *domain, LPCWSTR name, LPCWSTR data);
|
||||||
static cookie *COOKIE_findCookie(cookie_domain *domain, LPCSTR lpszCookieName);
|
static cookie *COOKIE_findCookie(cookie_domain *domain, LPCWSTR lpszCookieName);
|
||||||
static void COOKIE_deleteCookie(cookie *deadCookie, BOOL deleteDomain);
|
static void COOKIE_deleteCookie(cookie *deadCookie, BOOL deleteDomain);
|
||||||
static cookie_domain *COOKIE_addDomain(LPCSTR domain, LPCSTR path);
|
static cookie_domain *COOKIE_addDomain(LPCWSTR domain, LPCWSTR path);
|
||||||
static cookie_domain *COOKIE_addDomainFromUrl(LPCSTR lpszUrl);
|
static cookie_domain *COOKIE_addDomainFromUrl(LPCWSTR lpszUrl);
|
||||||
static cookie_domain *COOKIE_findNextDomain(LPCSTR lpszCookieDomain, LPCSTR lpszCookiePath,
|
static cookie_domain *COOKIE_findNextDomain(LPCWSTR lpszCookieDomain, LPCWSTR lpszCookiePath,
|
||||||
cookie_domain *prev_domain, BOOL allow_partial);
|
cookie_domain *prev_domain, BOOL allow_partial);
|
||||||
static cookie_domain *COOKIE_findNextDomainFromUrl(LPCSTR lpszUrl, cookie_domain *prev_domain,
|
static cookie_domain *COOKIE_findNextDomainFromUrl(LPCWSTR lpszUrl, cookie_domain *prev_domain,
|
||||||
BOOL allow_partial);
|
BOOL allow_partial);
|
||||||
static void COOKIE_deleteDomain(cookie_domain *deadDomain);
|
static void COOKIE_deleteDomain(cookie_domain *deadDomain);
|
||||||
|
|
||||||
|
|
||||||
/* adds a cookie to the domain */
|
/* adds a cookie to the domain */
|
||||||
static cookie *COOKIE_addCookie(cookie_domain *domain, LPCSTR name, LPCSTR data)
|
static cookie *COOKIE_addCookie(cookie_domain *domain, LPCWSTR name, LPCWSTR data)
|
||||||
{
|
{
|
||||||
cookie *newCookie = HeapAlloc(GetProcessHeap(), 0, sizeof(cookie));
|
cookie *newCookie = HeapAlloc(GetProcessHeap(), 0, sizeof(cookie));
|
||||||
|
|
||||||
|
@ -101,16 +101,16 @@ static cookie *COOKIE_addCookie(cookie_domain *domain, LPCSTR name, LPCSTR data)
|
||||||
|
|
||||||
if (name)
|
if (name)
|
||||||
{
|
{
|
||||||
newCookie->lpCookieName = HeapAlloc(GetProcessHeap(), 0, strlen(name) + 1);
|
newCookie->lpCookieName = HeapAlloc(GetProcessHeap(), 0, (strlenW(name) + 1)*sizeof(WCHAR));
|
||||||
strcpy(newCookie->lpCookieName, name);
|
lstrcpyW(newCookie->lpCookieName, name);
|
||||||
}
|
}
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
newCookie->lpCookieData = HeapAlloc(GetProcessHeap(), 0, strlen(data) + 1);
|
newCookie->lpCookieData = HeapAlloc(GetProcessHeap(), 0, (strlenW(data) + 1)*sizeof(WCHAR));
|
||||||
strcpy(newCookie->lpCookieData, data);
|
lstrcpyW(newCookie->lpCookieData, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("added cookie %p (data is %s)\n", newCookie, data);
|
TRACE("added cookie %p (data is %s)\n", newCookie, debugstr_w(data) );
|
||||||
|
|
||||||
newCookie->prev = domain->cookie_tail;
|
newCookie->prev = domain->cookie_tail;
|
||||||
newCookie->parent = domain;
|
newCookie->parent = domain;
|
||||||
|
@ -120,10 +120,10 @@ static cookie *COOKIE_addCookie(cookie_domain *domain, LPCSTR name, LPCSTR data)
|
||||||
|
|
||||||
|
|
||||||
/* finds a cookie in the domain matching the cookie name */
|
/* finds a cookie in the domain matching the cookie name */
|
||||||
static cookie *COOKIE_findCookie(cookie_domain *domain, LPCSTR lpszCookieName)
|
static cookie *COOKIE_findCookie(cookie_domain *domain, LPCWSTR lpszCookieName)
|
||||||
{
|
{
|
||||||
cookie *searchCookie = domain->cookie_tail;
|
cookie *searchCookie = domain->cookie_tail;
|
||||||
TRACE("(%p, %s)\n", domain, debugstr_a(lpszCookieName));
|
TRACE("(%p, %s)\n", domain, debugstr_w(lpszCookieName));
|
||||||
|
|
||||||
while (searchCookie)
|
while (searchCookie)
|
||||||
{
|
{
|
||||||
|
@ -132,7 +132,7 @@ static cookie *COOKIE_findCookie(cookie_domain *domain, LPCSTR lpszCookieName)
|
||||||
{
|
{
|
||||||
if (candidate && !searchCookie->lpCookieName)
|
if (candidate && !searchCookie->lpCookieName)
|
||||||
candidate = FALSE;
|
candidate = FALSE;
|
||||||
if (candidate && strcmp(lpszCookieName, searchCookie->lpCookieName) != 0)
|
if (candidate && strcmpW(lpszCookieName, searchCookie->lpCookieName) != 0)
|
||||||
candidate = FALSE;
|
candidate = FALSE;
|
||||||
}
|
}
|
||||||
if (candidate)
|
if (candidate)
|
||||||
|
@ -164,7 +164,7 @@ static void COOKIE_deleteCookie(cookie *deadCookie, BOOL deleteDomain)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocates a domain and adds it to the end */
|
/* allocates a domain and adds it to the end */
|
||||||
static cookie_domain *COOKIE_addDomain(LPCSTR domain, LPCSTR path)
|
static cookie_domain *COOKIE_addDomain(LPCWSTR domain, LPCWSTR path)
|
||||||
{
|
{
|
||||||
cookie_domain *newDomain = HeapAlloc(GetProcessHeap(), 0, sizeof(cookie_domain));
|
cookie_domain *newDomain = HeapAlloc(GetProcessHeap(), 0, sizeof(cookie_domain));
|
||||||
|
|
||||||
|
@ -176,13 +176,13 @@ static cookie_domain *COOKIE_addDomain(LPCSTR domain, LPCSTR path)
|
||||||
|
|
||||||
if (domain)
|
if (domain)
|
||||||
{
|
{
|
||||||
newDomain->lpCookieDomain = HeapAlloc(GetProcessHeap(), 0, strlen(domain) + 1);
|
newDomain->lpCookieDomain = HeapAlloc(GetProcessHeap(), 0, (strlenW(domain) + 1)*sizeof(WCHAR));
|
||||||
strcpy(newDomain->lpCookieDomain, domain);
|
strcpyW(newDomain->lpCookieDomain, domain);
|
||||||
}
|
}
|
||||||
if (path)
|
if (path)
|
||||||
{
|
{
|
||||||
newDomain->lpCookiePath = HeapAlloc(GetProcessHeap(), 0, strlen(path) + 1);
|
newDomain->lpCookiePath = HeapAlloc(GetProcessHeap(), 0, (strlenW(path) + 1)*sizeof(WCHAR));
|
||||||
strcpy(newDomain->lpCookiePath, path);
|
lstrcpyW(newDomain->lpCookiePath, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
newDomain->prev = cookieDomainTail;
|
newDomain->prev = cookieDomainTail;
|
||||||
|
@ -191,10 +191,10 @@ static cookie_domain *COOKIE_addDomain(LPCSTR domain, LPCSTR path)
|
||||||
return newDomain;
|
return newDomain;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cookie_domain *COOKIE_addDomainFromUrl(LPCSTR lpszUrl)
|
static cookie_domain *COOKIE_addDomainFromUrl(LPCWSTR lpszUrl)
|
||||||
{
|
{
|
||||||
char hostName[2048], path[2048];
|
WCHAR hostName[2048], path[2048];
|
||||||
URL_COMPONENTSA UrlComponents;
|
URL_COMPONENTSW UrlComponents;
|
||||||
|
|
||||||
UrlComponents.lpszExtraInfo = NULL;
|
UrlComponents.lpszExtraInfo = NULL;
|
||||||
UrlComponents.lpszPassword = NULL;
|
UrlComponents.lpszPassword = NULL;
|
||||||
|
@ -205,10 +205,10 @@ static cookie_domain *COOKIE_addDomainFromUrl(LPCSTR lpszUrl)
|
||||||
UrlComponents.dwHostNameLength = 2048;
|
UrlComponents.dwHostNameLength = 2048;
|
||||||
UrlComponents.dwUrlPathLength = 2048;
|
UrlComponents.dwUrlPathLength = 2048;
|
||||||
|
|
||||||
InternetCrackUrlA(lpszUrl, 0, 0, &UrlComponents);
|
InternetCrackUrlW(lpszUrl, 0, 0, &UrlComponents);
|
||||||
|
|
||||||
TRACE("Url cracked. Domain: %s, Path: %s.\n", debugstr_a(UrlComponents.lpszHostName),
|
TRACE("Url cracked. Domain: %s, Path: %s.\n", debugstr_w(UrlComponents.lpszHostName),
|
||||||
debugstr_a(UrlComponents.lpszUrlPath));
|
debugstr_w(UrlComponents.lpszUrlPath));
|
||||||
|
|
||||||
/* hack for now - FIXME - There seems to be a bug in InternetCrackUrl?? */
|
/* hack for now - FIXME - There seems to be a bug in InternetCrackUrl?? */
|
||||||
UrlComponents.lpszUrlPath = NULL;
|
UrlComponents.lpszUrlPath = NULL;
|
||||||
|
@ -217,7 +217,7 @@ static cookie_domain *COOKIE_addDomainFromUrl(LPCSTR lpszUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* find a domain. domain must match if its not NULL. path must match if its not NULL */
|
/* find a domain. domain must match if its not NULL. path must match if its not NULL */
|
||||||
static cookie_domain *COOKIE_findNextDomain(LPCSTR lpszCookieDomain, LPCSTR lpszCookiePath,
|
static cookie_domain *COOKIE_findNextDomain(LPCWSTR lpszCookieDomain, LPCWSTR lpszCookiePath,
|
||||||
cookie_domain *prev_domain, BOOL allow_partial)
|
cookie_domain *prev_domain, BOOL allow_partial)
|
||||||
{
|
{
|
||||||
cookie_domain *searchDomain;
|
cookie_domain *searchDomain;
|
||||||
|
@ -242,18 +242,22 @@ static cookie_domain *COOKIE_findNextDomain(LPCSTR lpszCookieDomain, LPCSTR lpsz
|
||||||
if (candidate && !searchDomain->lpCookieDomain)
|
if (candidate && !searchDomain->lpCookieDomain)
|
||||||
candidate = FALSE;
|
candidate = FALSE;
|
||||||
TRACE("candidate! (%p)\n", searchDomain->lpCookieDomain);
|
TRACE("candidate! (%p)\n", searchDomain->lpCookieDomain);
|
||||||
TRACE("comparing domain %s with %s\n", lpszCookieDomain, searchDomain->lpCookieDomain);
|
TRACE("comparing domain %s with %s\n",
|
||||||
if (candidate && allow_partial && !strstr(lpszCookieDomain, searchDomain->lpCookieDomain))
|
debugstr_w(lpszCookieDomain),
|
||||||
|
debugstr_w(searchDomain->lpCookieDomain));
|
||||||
|
if (candidate && allow_partial && !strstrW(lpszCookieDomain, searchDomain->lpCookieDomain))
|
||||||
candidate = FALSE;
|
candidate = FALSE;
|
||||||
else if (candidate && !allow_partial &&
|
else if (candidate && !allow_partial &&
|
||||||
strcmp(lpszCookieDomain, searchDomain->lpCookieDomain) != 0)
|
lstrcmpW(lpszCookieDomain, searchDomain->lpCookieDomain) != 0)
|
||||||
candidate = FALSE;
|
candidate = FALSE;
|
||||||
}
|
}
|
||||||
if (candidate && lpszCookiePath)
|
if (candidate && lpszCookiePath)
|
||||||
{ TRACE("comparing paths\n");
|
{
|
||||||
|
TRACE("comparing paths\n");
|
||||||
if (candidate && !searchDomain->lpCookiePath)
|
if (candidate && !searchDomain->lpCookiePath)
|
||||||
candidate = FALSE;
|
candidate = FALSE;
|
||||||
if (candidate && strcmp(lpszCookiePath, searchDomain->lpCookiePath) != 0)
|
if (candidate &&
|
||||||
|
strcmpW(lpszCookiePath, searchDomain->lpCookiePath))
|
||||||
candidate = FALSE;
|
candidate = FALSE;
|
||||||
}
|
}
|
||||||
if (candidate)
|
if (candidate)
|
||||||
|
@ -267,11 +271,11 @@ static cookie_domain *COOKIE_findNextDomain(LPCSTR lpszCookieDomain, LPCSTR lpsz
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cookie_domain *COOKIE_findNextDomainFromUrl(LPCSTR lpszUrl, cookie_domain *previous_domain,
|
static cookie_domain *COOKIE_findNextDomainFromUrl(LPCWSTR lpszUrl, cookie_domain *previous_domain,
|
||||||
BOOL allow_partial)
|
BOOL allow_partial)
|
||||||
{
|
{
|
||||||
char hostName[2048], path[2048];
|
WCHAR hostName[2048], path[2048];
|
||||||
URL_COMPONENTSA UrlComponents;
|
URL_COMPONENTSW UrlComponents;
|
||||||
|
|
||||||
UrlComponents.lpszExtraInfo = NULL;
|
UrlComponents.lpszExtraInfo = NULL;
|
||||||
UrlComponents.lpszPassword = NULL;
|
UrlComponents.lpszPassword = NULL;
|
||||||
|
@ -282,10 +286,11 @@ static cookie_domain *COOKIE_findNextDomainFromUrl(LPCSTR lpszUrl, cookie_domain
|
||||||
UrlComponents.dwHostNameLength = 2048;
|
UrlComponents.dwHostNameLength = 2048;
|
||||||
UrlComponents.dwUrlPathLength = 2048;
|
UrlComponents.dwUrlPathLength = 2048;
|
||||||
|
|
||||||
InternetCrackUrlA(lpszUrl, 0, 0, &UrlComponents);
|
InternetCrackUrlW(lpszUrl, 0, 0, &UrlComponents);
|
||||||
|
|
||||||
TRACE("Url cracked. Domain: %s, Path: %s.\n", debugstr_a(UrlComponents.lpszHostName),
|
TRACE("Url cracked. Domain: %s, Path: %s.\n",
|
||||||
debugstr_a(UrlComponents.lpszUrlPath));
|
debugstr_w(UrlComponents.lpszHostName),
|
||||||
|
debugstr_w(UrlComponents.lpszUrlPath));
|
||||||
|
|
||||||
/* hack for now - FIXME - There seems to be a bug in InternetCrackUrl?? */
|
/* hack for now - FIXME - There seems to be a bug in InternetCrackUrl?? */
|
||||||
UrlComponents.lpszUrlPath = NULL;
|
UrlComponents.lpszUrlPath = NULL;
|
||||||
|
@ -314,7 +319,7 @@ static void COOKIE_deleteDomain(cookie_domain *deadDomain)
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* InternetGetCookieA (WININET.@)
|
* InternetGetCookieW (WININET.@)
|
||||||
*
|
*
|
||||||
* Retrieve cookie from the specified url
|
* Retrieve cookie from the specified url
|
||||||
*
|
*
|
||||||
|
@ -326,8 +331,8 @@ static void COOKIE_deleteDomain(cookie_domain *deadDomain)
|
||||||
* FALSE on failure
|
* FALSE on failure
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
|
BOOL WINAPI InternetGetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
|
||||||
LPSTR lpCookieData, LPDWORD lpdwSize)
|
LPWSTR lpCookieData, LPDWORD lpdwSize)
|
||||||
{
|
{
|
||||||
cookie_domain *cookiesDomain = NULL;
|
cookie_domain *cookiesDomain = NULL;
|
||||||
cookie *thisCookie;
|
cookie *thisCookie;
|
||||||
|
@ -338,15 +343,19 @@ BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
|
||||||
* It'd be nice to know what exactly is going on, M$ tracking users? Does this need
|
* It'd be nice to know what exactly is going on, M$ tracking users? Does this need
|
||||||
* to be unique? Should I generate a random number here? etc.
|
* to be unique? Should I generate a random number here? etc.
|
||||||
*/
|
*/
|
||||||
char *TrackingString = "MtrxTrackingID=01234567890123456789012345678901";
|
WCHAR TrackingString[] = {
|
||||||
|
'M','t','r','x','T','r','a','c','k','i','n','g','I','D','=',
|
||||||
|
'0','1','2','3','4','5','6','7','8','9','0','1','2','3','4','5',
|
||||||
|
'6','7','8','9','0','1','2','3','4','5','6','7','8','9','0','1', 0 };
|
||||||
|
WCHAR szps[] = { '%','s',0 };
|
||||||
|
|
||||||
TRACE("(%s, %s, %p, %p)\n", debugstr_a(lpszUrl),debugstr_a(lpszCookieName),
|
TRACE("(%s, %s, %p, %p)\n", debugstr_w(lpszUrl),debugstr_w(lpszCookieName),
|
||||||
lpCookieData, lpdwSize);
|
lpCookieData, lpdwSize);
|
||||||
|
|
||||||
if (lpCookieData)
|
if (lpCookieData)
|
||||||
cnt += snprintf(lpCookieData + cnt, *lpdwSize - cnt, "%s", TrackingString);
|
cnt += snprintfW(lpCookieData + cnt, *lpdwSize - cnt, szps, TrackingString);
|
||||||
else
|
else
|
||||||
cnt += strlen(TrackingString);
|
cnt += strlenW(TrackingString);
|
||||||
|
|
||||||
while ((cookiesDomain = COOKIE_findNextDomainFromUrl(lpszUrl, cookiesDomain, TRUE)))
|
while ((cookiesDomain = COOKIE_findNextDomainFromUrl(lpszUrl, cookiesDomain, TRUE)))
|
||||||
{
|
{
|
||||||
|
@ -359,17 +368,20 @@ BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
|
||||||
while (thisCookie)
|
while (thisCookie)
|
||||||
{
|
{
|
||||||
cnt += 2; /* '; ' */
|
cnt += 2; /* '; ' */
|
||||||
cnt += strlen(thisCookie->lpCookieName);
|
cnt += strlenW(thisCookie->lpCookieName);
|
||||||
cnt += 1; /* = */
|
cnt += 1; /* = */
|
||||||
cnt += strlen(thisCookie->lpCookieData);
|
cnt += strlenW(thisCookie->lpCookieData);
|
||||||
|
|
||||||
thisCookie = thisCookie->prev;
|
thisCookie = thisCookie->prev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (thisCookie)
|
while (thisCookie)
|
||||||
{
|
{
|
||||||
cnt += snprintf(lpCookieData + cnt, *lpdwSize - cnt, "; ");
|
WCHAR szsc[] = { ';',' ',0 };
|
||||||
cnt += snprintf(lpCookieData + cnt, *lpdwSize - cnt, "%s=%s", thisCookie->lpCookieName,
|
WCHAR szpseq[] = { '%','s','=','%','s',0 };
|
||||||
|
cnt += snprintfW(lpCookieData + cnt, *lpdwSize - cnt, szsc);
|
||||||
|
cnt += snprintfW(lpCookieData + cnt, *lpdwSize - cnt, szpseq,
|
||||||
|
thisCookie->lpCookieName,
|
||||||
thisCookie->lpCookieData);
|
thisCookie->lpCookieData);
|
||||||
|
|
||||||
thisCookie = thisCookie->prev;
|
thisCookie = thisCookie->prev;
|
||||||
|
@ -388,14 +400,15 @@ BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
|
||||||
|
|
||||||
*lpdwSize = cnt + 1;
|
*lpdwSize = cnt + 1;
|
||||||
|
|
||||||
TRACE("Returning %i (from %i domains): %s\n", cnt, domain_count, lpCookieData);
|
TRACE("Returning %i (from %i domains): %s\n", cnt, domain_count,
|
||||||
|
debugstr_w(lpCookieData));
|
||||||
|
|
||||||
return (cnt ? TRUE : FALSE);
|
return (cnt ? TRUE : FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* InternetGetCookieW (WININET.@)
|
* InternetGetCookieA (WININET.@)
|
||||||
*
|
*
|
||||||
* Retrieve cookie from the specified url
|
* Retrieve cookie from the specified url
|
||||||
*
|
*
|
||||||
|
@ -404,72 +417,51 @@ BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
|
||||||
* FALSE on failure
|
* FALSE on failure
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI InternetGetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
|
BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
|
||||||
LPWSTR lpCookieData, LPDWORD lpdwSize)
|
LPSTR lpCookieData, LPDWORD lpdwSize)
|
||||||
{
|
{
|
||||||
FIXME("STUB\n");
|
DWORD len;
|
||||||
TRACE("(%s,%s,%p)\n", debugstr_w(lpszUrl), debugstr_w(lpszCookieName),
|
LPWSTR szCookieData = NULL, szUrl = NULL, szCookieName = NULL;
|
||||||
|
BOOL r;
|
||||||
|
|
||||||
|
TRACE("(%s,%s,%p)\n", debugstr_a(lpszUrl), debugstr_a(lpszCookieName),
|
||||||
lpCookieData);
|
lpCookieData);
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if( lpszUrl )
|
||||||
/***********************************************************************
|
|
||||||
* InternetSetCookieA (WININET.@)
|
|
||||||
*
|
|
||||||
* Sets cookie for the specified url
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* TRUE on success
|
|
||||||
* FALSE on failure
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
BOOL WINAPI InternetSetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
|
|
||||||
LPCSTR lpCookieData)
|
|
||||||
{
|
|
||||||
cookie *thisCookie;
|
|
||||||
cookie_domain *thisCookieDomain;
|
|
||||||
|
|
||||||
TRACE("(%s,%s,%s)\n", debugstr_a(lpszUrl),
|
|
||||||
debugstr_a(lpszCookieName), lpCookieData);
|
|
||||||
|
|
||||||
if (!lpCookieData || !strlen(lpCookieData))
|
|
||||||
{
|
{
|
||||||
TRACE("no cookie data, not adding\n");
|
len = MultiByteToWideChar( CP_ACP, 0, lpszUrl, -1, NULL, 0 );
|
||||||
return FALSE;
|
szUrl = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
||||||
}
|
MultiByteToWideChar( CP_ACP, 0, lpszUrl, -1, szUrl, len );
|
||||||
if (!lpszCookieName)
|
|
||||||
{
|
|
||||||
/* some apps (or is it us??) try to add a cookie with no cookie name, but
|
|
||||||
* the cookie data in the form of name=data. */
|
|
||||||
/* FIXME, probably a bug here, for now I don't care */
|
|
||||||
char *ourCookieName, *ourCookieData;
|
|
||||||
int ourCookieNameSize;
|
|
||||||
BOOL ret;
|
|
||||||
if (!(ourCookieData = strchr(lpCookieData, '=')))
|
|
||||||
{
|
|
||||||
TRACE("something terribly wrong with cookie data %s\n", ourCookieData);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
ourCookieNameSize = ourCookieData - lpCookieData;
|
|
||||||
ourCookieData += 1;
|
|
||||||
ourCookieName = HeapAlloc(GetProcessHeap(), 0, ourCookieNameSize + 1);
|
|
||||||
strncpy(ourCookieName, ourCookieData, ourCookieNameSize);
|
|
||||||
ourCookieName[ourCookieNameSize] = '\0';
|
|
||||||
TRACE("setting (hacked) cookie of %s, %s\n", ourCookieName, ourCookieData);
|
|
||||||
ret = InternetSetCookieA(lpszUrl, ourCookieName, ourCookieData);
|
|
||||||
HeapFree(GetProcessHeap(), 0, ourCookieName);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(thisCookieDomain = COOKIE_findNextDomainFromUrl(lpszUrl, NULL, FALSE)))
|
if( lpszCookieName )
|
||||||
thisCookieDomain = COOKIE_addDomainFromUrl(lpszUrl);
|
{
|
||||||
|
len = MultiByteToWideChar( CP_ACP, 0, lpszCookieName, -1, NULL, 0 );
|
||||||
|
szCookieName = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
||||||
|
MultiByteToWideChar( CP_ACP, 0, lpszCookieName, -1, szCookieName, len );
|
||||||
|
}
|
||||||
|
|
||||||
if ((thisCookie = COOKIE_findCookie(thisCookieDomain, lpszCookieName)))
|
r = InternetGetCookieW( szUrl, szCookieName, NULL, &len );
|
||||||
COOKIE_deleteCookie(thisCookie, FALSE);
|
if( r )
|
||||||
|
{
|
||||||
|
szCookieData = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
||||||
|
if( !szCookieData )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
thisCookie = COOKIE_addCookie(thisCookieDomain, lpszCookieName, lpCookieData);
|
r = InternetGetCookieW( szUrl, szCookieName, szCookieData, &len );
|
||||||
return TRUE;
|
|
||||||
|
*lpdwSize = WideCharToMultiByte( CP_ACP, 0, szCookieData, len,
|
||||||
|
lpCookieData, *lpdwSize, NULL, NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( szCookieData )
|
||||||
|
HeapFree( GetProcessHeap(), 0, szCookieData );
|
||||||
|
if( szCookieName )
|
||||||
|
HeapFree( GetProcessHeap(), 0, szCookieName );
|
||||||
|
if( szUrl )
|
||||||
|
HeapFree( GetProcessHeap(), 0, szUrl );
|
||||||
|
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -486,8 +478,104 @@ BOOL WINAPI InternetSetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
|
||||||
BOOL WINAPI InternetSetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
|
BOOL WINAPI InternetSetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
|
||||||
LPCWSTR lpCookieData)
|
LPCWSTR lpCookieData)
|
||||||
{
|
{
|
||||||
FIXME("STUB\n");
|
cookie *thisCookie;
|
||||||
|
cookie_domain *thisCookieDomain;
|
||||||
|
|
||||||
TRACE("(%s,%s,%s)\n", debugstr_w(lpszUrl),
|
TRACE("(%s,%s,%s)\n", debugstr_w(lpszUrl),
|
||||||
debugstr_w(lpszCookieName), debugstr_w(lpCookieData));
|
debugstr_w(lpszCookieName), debugstr_w(lpCookieData));
|
||||||
|
|
||||||
|
if (!lpCookieData || !strlenW(lpCookieData))
|
||||||
|
{
|
||||||
|
TRACE("no cookie data, not adding\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (!lpszCookieName)
|
||||||
|
{
|
||||||
|
/* some apps (or is it us??) try to add a cookie with no cookie name, but
|
||||||
|
* the cookie data in the form of name=data. */
|
||||||
|
/* FIXME, probably a bug here, for now I don't care */
|
||||||
|
WCHAR *ourCookieName, *ourCookieData;
|
||||||
|
int ourCookieNameSize;
|
||||||
|
BOOL ret;
|
||||||
|
if (!(ourCookieData = strchrW(lpCookieData, '=')))
|
||||||
|
{
|
||||||
|
TRACE("something terribly wrong with cookie data %s\n",
|
||||||
|
debugstr_w(ourCookieData));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
ourCookieNameSize = ourCookieData - lpCookieData;
|
||||||
|
ourCookieData += 1;
|
||||||
|
ourCookieName = HeapAlloc(GetProcessHeap(), 0,
|
||||||
|
(ourCookieNameSize + 1)*sizeof(WCHAR));
|
||||||
|
strncpyW(ourCookieName, ourCookieData, ourCookieNameSize);
|
||||||
|
ourCookieName[ourCookieNameSize] = '\0';
|
||||||
|
TRACE("setting (hacked) cookie of %s, %s\n",
|
||||||
|
debugstr_w(ourCookieName), debugstr_w(ourCookieData));
|
||||||
|
ret = InternetSetCookieW(lpszUrl, ourCookieName, ourCookieData);
|
||||||
|
HeapFree(GetProcessHeap(), 0, ourCookieName);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(thisCookieDomain = COOKIE_findNextDomainFromUrl(lpszUrl, NULL, FALSE)))
|
||||||
|
thisCookieDomain = COOKIE_addDomainFromUrl(lpszUrl);
|
||||||
|
|
||||||
|
if ((thisCookie = COOKIE_findCookie(thisCookieDomain, lpszCookieName)))
|
||||||
|
COOKIE_deleteCookie(thisCookie, FALSE);
|
||||||
|
|
||||||
|
thisCookie = COOKIE_addCookie(thisCookieDomain, lpszCookieName, lpCookieData);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* InternetSetCookieA (WININET.@)
|
||||||
|
*
|
||||||
|
* Sets cookie for the specified url
|
||||||
|
*
|
||||||
|
* RETURNS
|
||||||
|
* TRUE on success
|
||||||
|
* FALSE on failure
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
BOOL WINAPI InternetSetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
|
||||||
|
LPCSTR lpCookieData)
|
||||||
|
{
|
||||||
|
DWORD len;
|
||||||
|
LPWSTR szCookieData = NULL, szUrl = NULL, szCookieName = NULL;
|
||||||
|
BOOL r;
|
||||||
|
|
||||||
|
TRACE("(%s,%s,%s)\n", debugstr_a(lpszUrl),
|
||||||
|
debugstr_a(lpszCookieName), debugstr_a(lpCookieData));
|
||||||
|
|
||||||
|
if( lpszUrl )
|
||||||
|
{
|
||||||
|
len = MultiByteToWideChar( CP_ACP, 0, lpszUrl, -1, NULL, 0 );
|
||||||
|
szUrl = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
||||||
|
MultiByteToWideChar( CP_ACP, 0, lpszUrl, -1, szUrl, len );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( lpszCookieName )
|
||||||
|
{
|
||||||
|
len = MultiByteToWideChar( CP_ACP, 0, lpszCookieName, -1, NULL, 0 );
|
||||||
|
szCookieName = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
||||||
|
MultiByteToWideChar( CP_ACP, 0, lpszCookieName, -1, szCookieName, len );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( lpCookieData )
|
||||||
|
{
|
||||||
|
len = MultiByteToWideChar( CP_ACP, 0, lpCookieData, -1, NULL, 0 );
|
||||||
|
szCookieData = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
||||||
|
MultiByteToWideChar( CP_ACP, 0, lpCookieData, -1, szCookieData, len );
|
||||||
|
}
|
||||||
|
|
||||||
|
r = InternetSetCookieW( szUrl, szCookieName, szCookieData );
|
||||||
|
|
||||||
|
if( szCookieData )
|
||||||
|
HeapFree( GetProcessHeap(), 0, szCookieData );
|
||||||
|
if( szCookieName )
|
||||||
|
HeapFree( GetProcessHeap(), 0, szCookieName );
|
||||||
|
if( szUrl )
|
||||||
|
HeapFree( GetProcessHeap(), 0, szUrl );
|
||||||
|
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue