Module: wine Branch: master Commit: 8aa93c41f0f3dd772d09883968ada19a5ab0a724 URL: http://source.winehq.org/git/wine.git/?a=commit;h=8aa93c41f0f3dd772d09883968...
Author: Aric Stewart aric@codeweavers.com Date: Tue Feb 17 10:28:46 2009 -0600
wininet: Parse cookie information from cookie value.
---
dlls/wininet/cookie.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 49 insertions(+), 3 deletions(-)
diff --git a/dlls/wininet/cookie.c b/dlls/wininet/cookie.c index c6352c8..1a4b5fb 100644 --- a/dlls/wininet/cookie.c +++ b/dlls/wininet/cookie.c @@ -409,6 +409,48 @@ static BOOL set_cookie(LPCWSTR domain, LPCWSTR path, LPCWSTR cookie_name, LPCWST cookie_domain *thisCookieDomain = NULL; cookie *thisCookie; struct list *cursor; + LPWSTR data; + WCHAR *ptr; + + data = HeapAlloc(GetProcessHeap(),0,(lstrlenW(cookie_data)+1) * sizeof(WCHAR)); + strcpyW(data,cookie_data); + + /* lots of informations can be parsed out of the cookie value */ + + ptr = data; + for (;;) + { + static const WCHAR szDomain[] = {'d','o','m','a','i','n','=',0}; + static const WCHAR szPath[] = {'p','a','t','h','=',0}; + static const WCHAR szExpires[] = {'e','x','p','i','r','e','s','=',0}; + static const WCHAR szSecure[] = {'s','e','c','u','r','e',0}; + static const WCHAR szHttpOnly[] = {'h','t','t','p','o','n','l','y',0}; + + if (!(ptr = strchrW(ptr,';'))) break; + *ptr++ = 0; + while (*ptr == ' ') ptr++; /* whitespace */ + + if (strncmpiW(ptr, szDomain, 7) == 0) + { + ptr+=strlenW(szDomain); + domain = ptr; + TRACE("Parsing new domain %s\n",debugstr_w(domain)); + } + else if (strncmpiW(ptr, szPath, 5) == 0) + { + ptr+=strlenW(szPath); + path = ptr; + TRACE("Parsing new path %s\n",debugstr_w(path)); + } + else if (strncmpiW(ptr, szExpires, 8) == 0) + FIXME("expires not handled (%s)\n",debugstr_w(ptr)); + else if (strncmpiW(ptr, szSecure, 6) == 0) + FIXME("secure not handled (%s)\n",debugstr_w(ptr)); + else if (strncmpiW(ptr, szHttpOnly, 8) == 0) + FIXME("httponly not handled (%s)\n",debugstr_w(ptr)); + else + FIXME("Unknown additional option %s\n",debugstr_w(ptr)); + }
LIST_FOR_EACH(cursor, &domain_list) { @@ -425,11 +467,15 @@ static BOOL set_cookie(LPCWSTR domain, LPCWSTR path, LPCWSTR cookie_name, LPCWST COOKIE_deleteCookie(thisCookie, FALSE);
TRACE("setting cookie %s=%s for domain %s\n", debugstr_w(cookie_name), - debugstr_w(cookie_data), debugstr_w(thisCookieDomain->lpCookieDomain)); + debugstr_w(data), debugstr_w(thisCookieDomain->lpCookieDomain));
- if (!COOKIE_addCookie(thisCookieDomain, cookie_name, cookie_data)) + if (!COOKIE_addCookie(thisCookieDomain, cookie_name,data)) + { + HeapFree(GetProcessHeap(),0,data); return FALSE; + }
+ HeapFree(GetProcessHeap(),0,data); return TRUE; }
@@ -479,7 +525,7 @@ BOOL WINAPI InternetSetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName, * the cookie data in the form of name[=data]. */ if (!(data = strchrW(cookie, '='))) data = cookie + len; - else data++; + else *data++ = 0;
ret = set_cookie(hostName, path, cookie, data);