Home | Info | Community | Development | myReactOS | Contact Us
Definition at line 417 of file cookie.c.
Referenced by HTTP_ProcessCookies(), InternetSetCookieW(), and record_cookies().
{ cookie_domain *thisCookieDomain = NULL; cookie *thisCookie; struct list *cursor; LPWSTR data, value; WCHAR *ptr; FILETIME expiry; BOOL expired = FALSE; value = data = heap_strdupW(cookie_data); if (!data) { ERR("could not allocate the cookie data buffer\n"); return FALSE; } memset(&expiry,0,sizeof(expiry)); /* lots of information 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; if (value != data) HeapFree(GetProcessHeap(), 0, value); value = heap_alloc((ptr - data) * sizeof(WCHAR)); if (value == NULL) { HeapFree(GetProcessHeap(), 0, data); ERR("could not allocate the cookie value buffer\n"); return FALSE; } strcpyW(value, data); 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) { FILETIME ft; SYSTEMTIME st; FIXME("persistent cookies not handled (%s)\n",debugstr_w(ptr)); ptr+=strlenW(szExpires); if (InternetTimeToSystemTimeW(ptr, &st, 0)) { SystemTimeToFileTime(&st, &expiry); GetSystemTimeAsFileTime(&ft); if (CompareFileTime(&ft,&expiry) > 0) { TRACE("Cookie already expired.\n"); expired = TRUE; } } } else if (strncmpiW(ptr, szSecure, 6) == 0) { FIXME("secure not handled (%s)\n",debugstr_w(ptr)); ptr += strlenW(szSecure); } else if (strncmpiW(ptr, szHttpOnly, 8) == 0) { FIXME("httponly not handled (%s)\n",debugstr_w(ptr)); ptr += strlenW(szHttpOnly); } else if (*ptr) { FIXME("Unknown additional option %s\n",debugstr_w(ptr)); break; } } LIST_FOR_EACH(cursor, &domain_list) { thisCookieDomain = LIST_ENTRY(cursor, cookie_domain, entry); if (COOKIE_matchDomain(domain, path, thisCookieDomain, FALSE)) break; thisCookieDomain = NULL; } if (!thisCookieDomain) { if (!expired) thisCookieDomain = COOKIE_addDomain(domain, path); else { HeapFree(GetProcessHeap(),0,data); if (value != data) HeapFree(GetProcessHeap(), 0, value); return TRUE; } } if ((thisCookie = COOKIE_findCookie(thisCookieDomain, cookie_name))) COOKIE_deleteCookie(thisCookie, FALSE); TRACE("setting cookie %s=%s for domain %s path %s\n", debugstr_w(cookie_name), debugstr_w(value), debugstr_w(thisCookieDomain->lpCookieDomain),debugstr_w(thisCookieDomain->lpCookiePath)); if (!expired && !COOKIE_addCookie(thisCookieDomain, cookie_name, value, expiry)) { HeapFree(GetProcessHeap(),0,data); if (value != data) HeapFree(GetProcessHeap(), 0, value); return FALSE; } HeapFree(GetProcessHeap(),0,data); if (value != data) HeapFree(GetProcessHeap(), 0, value); return TRUE; }