Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
44ef9a1f
Commit
44ef9a1f
authored
Mar 30, 2004
by
Mike McCormack
Committed by
Alexandre Julliard
Mar 30, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unicodify the cookie handling code.
parent
1baf39f9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
167 additions
and
79 deletions
+167
-79
cookie.c
dlls/wininet/cookie.c
+167
-79
No files found.
dlls/wininet/cookie.c
View file @
44ef9a1f
...
...
@@ -60,8 +60,8 @@ struct _cookie
struct
_cookie_domain
*
parent
;
LPSTR
lpCookieName
;
LPSTR
lpCookieData
;
LP
W
STR
lpCookieName
;
LP
W
STR
lpCookieData
;
time_t
expiry
;
/* FIXME: not used */
};
...
...
@@ -70,27 +70,27 @@ struct _cookie_domain
struct
_cookie_domain
*
next
;
struct
_cookie_domain
*
prev
;
LPSTR
lpCookieDomain
;
LPSTR
lpCookiePath
;
LP
W
STR
lpCookieDomain
;
LP
W
STR
lpCookiePath
;
cookie
*
cookie_tail
;
};
static
cookie_domain
*
cookieDomainTail
;
static
cookie
*
COOKIE_addCookie
(
cookie_domain
*
domain
,
LPC
STR
name
,
LPC
STR
data
);
static
cookie
*
COOKIE_findCookie
(
cookie_domain
*
domain
,
LPCSTR
lpszCookieName
);
static
cookie
*
COOKIE_addCookie
(
cookie_domain
*
domain
,
LPC
WSTR
name
,
LPCW
STR
data
);
static
cookie
*
COOKIE_findCookie
(
cookie_domain
*
domain
,
LPC
W
STR
lpszCookieName
);
static
void
COOKIE_deleteCookie
(
cookie
*
deadCookie
,
BOOL
deleteDomain
);
static
cookie_domain
*
COOKIE_addDomain
(
LPC
STR
domain
,
LPC
STR
path
);
static
cookie_domain
*
COOKIE_addDomainFromUrl
(
LPCSTR
lpszUrl
);
static
cookie_domain
*
COOKIE_findNextDomain
(
LPC
STR
lpszCookieDomain
,
LPC
STR
lpszCookiePath
,
static
cookie_domain
*
COOKIE_addDomain
(
LPC
WSTR
domain
,
LPCW
STR
path
);
static
cookie_domain
*
COOKIE_addDomainFromUrl
(
LPC
W
STR
lpszUrl
);
static
cookie_domain
*
COOKIE_findNextDomain
(
LPC
WSTR
lpszCookieDomain
,
LPCW
STR
lpszCookiePath
,
cookie_domain
*
prev_domain
,
BOOL
allow_partial
);
static
cookie_domain
*
COOKIE_findNextDomainFromUrl
(
LPCSTR
lpszUrl
,
cookie_domain
*
prev_domain
,
static
cookie_domain
*
COOKIE_findNextDomainFromUrl
(
LPC
W
STR
lpszUrl
,
cookie_domain
*
prev_domain
,
BOOL
allow_partial
);
static
void
COOKIE_deleteDomain
(
cookie_domain
*
deadDomain
);
/* adds a cookie to the domain */
static
cookie
*
COOKIE_addCookie
(
cookie_domain
*
domain
,
LPC
STR
name
,
LPC
STR
data
)
static
cookie
*
COOKIE_addCookie
(
cookie_domain
*
domain
,
LPC
WSTR
name
,
LPCW
STR
data
)
{
cookie
*
newCookie
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
cookie
));
...
...
@@ -101,16 +101,16 @@ static cookie *COOKIE_addCookie(cookie_domain *domain, LPCSTR name, LPCSTR data)
if
(
name
)
{
newCookie
->
lpCookieName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
name
)
+
1
);
strcpy
(
newCookie
->
lpCookieName
,
name
);
newCookie
->
lpCookieName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
strlenW
(
name
)
+
1
)
*
sizeof
(
WCHAR
)
);
lstrcpyW
(
newCookie
->
lpCookieName
,
name
);
}
if
(
data
)
{
newCookie
->
lpCookieData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
data
)
+
1
);
strcpy
(
newCookie
->
lpCookieData
,
data
);
newCookie
->
lpCookieData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
strlenW
(
data
)
+
1
)
*
sizeof
(
WCHAR
)
);
lstrcpyW
(
newCookie
->
lpCookieData
,
data
);
}
TRACE
(
"added cookie %p (data is %s)
\n
"
,
newCookie
,
d
ata
);
TRACE
(
"added cookie %p (data is %s)
\n
"
,
newCookie
,
d
ebugstr_w
(
data
)
);
newCookie
->
prev
=
domain
->
cookie_tail
;
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 */
static
cookie
*
COOKIE_findCookie
(
cookie_domain
*
domain
,
LPCSTR
lpszCookieName
)
static
cookie
*
COOKIE_findCookie
(
cookie_domain
*
domain
,
LPC
W
STR
lpszCookieName
)
{
cookie
*
searchCookie
=
domain
->
cookie_tail
;
TRACE
(
"(%p, %s)
\n
"
,
domain
,
debugstr_
a
(
lpszCookieName
));
TRACE
(
"(%p, %s)
\n
"
,
domain
,
debugstr_
w
(
lpszCookieName
));
while
(
searchCookie
)
{
...
...
@@ -132,7 +132,7 @@ static cookie *COOKIE_findCookie(cookie_domain *domain, LPCSTR lpszCookieName)
{
if
(
candidate
&&
!
searchCookie
->
lpCookieName
)
candidate
=
FALSE
;
if
(
candidate
&&
strcmp
(
lpszCookieName
,
searchCookie
->
lpCookieName
)
!=
0
)
if
(
candidate
&&
strcmp
W
(
lpszCookieName
,
searchCookie
->
lpCookieName
)
!=
0
)
candidate
=
FALSE
;
}
if
(
candidate
)
...
...
@@ -164,7 +164,7 @@ static void COOKIE_deleteCookie(cookie *deadCookie, BOOL deleteDomain)
}
/* allocates a domain and adds it to the end */
static
cookie_domain
*
COOKIE_addDomain
(
LPC
STR
domain
,
LPC
STR
path
)
static
cookie_domain
*
COOKIE_addDomain
(
LPC
WSTR
domain
,
LPCW
STR
path
)
{
cookie_domain
*
newDomain
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
cookie_domain
));
...
...
@@ -176,13 +176,13 @@ static cookie_domain *COOKIE_addDomain(LPCSTR domain, LPCSTR path)
if
(
domain
)
{
newDomain
->
lpCookieDomain
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
domain
)
+
1
);
strcpy
(
newDomain
->
lpCookieDomain
,
domain
);
newDomain
->
lpCookieDomain
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
strlenW
(
domain
)
+
1
)
*
sizeof
(
WCHAR
)
);
strcpy
W
(
newDomain
->
lpCookieDomain
,
domain
);
}
if
(
path
)
{
newDomain
->
lpCookiePath
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
path
)
+
1
);
strcpy
(
newDomain
->
lpCookiePath
,
path
);
newDomain
->
lpCookiePath
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
strlenW
(
path
)
+
1
)
*
sizeof
(
WCHAR
)
);
lstrcpyW
(
newDomain
->
lpCookiePath
,
path
);
}
newDomain
->
prev
=
cookieDomainTail
;
...
...
@@ -191,10 +191,10 @@ static cookie_domain *COOKIE_addDomain(LPCSTR domain, LPCSTR path)
return
newDomain
;
}
static
cookie_domain
*
COOKIE_addDomainFromUrl
(
LPCSTR
lpszUrl
)
static
cookie_domain
*
COOKIE_addDomainFromUrl
(
LPC
W
STR
lpszUrl
)
{
char
hostName
[
2048
],
path
[
2048
];
URL_COMPONENTS
A
UrlComponents
;
WCHAR
hostName
[
2048
],
path
[
2048
];
URL_COMPONENTS
W
UrlComponents
;
UrlComponents
.
lpszExtraInfo
=
NULL
;
UrlComponents
.
lpszPassword
=
NULL
;
...
...
@@ -205,10 +205,10 @@ static cookie_domain *COOKIE_addDomainFromUrl(LPCSTR lpszUrl)
UrlComponents
.
dwHostNameLength
=
2048
;
UrlComponents
.
dwUrlPathLength
=
2048
;
InternetCrackUrl
A
(
lpszUrl
,
0
,
0
,
&
UrlComponents
);
InternetCrackUrl
W
(
lpszUrl
,
0
,
0
,
&
UrlComponents
);
TRACE
(
"Url cracked. Domain: %s, Path: %s.
\n
"
,
debugstr_
a
(
UrlComponents
.
lpszHostName
),
debugstr_
a
(
UrlComponents
.
lpszUrlPath
));
TRACE
(
"Url cracked. Domain: %s, Path: %s.
\n
"
,
debugstr_
w
(
UrlComponents
.
lpszHostName
),
debugstr_
w
(
UrlComponents
.
lpszUrlPath
));
/* hack for now - FIXME - There seems to be a bug in InternetCrackUrl?? */
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 */
static
cookie_domain
*
COOKIE_findNextDomain
(
LPC
STR
lpszCookieDomain
,
LPC
STR
lpszCookiePath
,
static
cookie_domain
*
COOKIE_findNextDomain
(
LPC
WSTR
lpszCookieDomain
,
LPCW
STR
lpszCookiePath
,
cookie_domain
*
prev_domain
,
BOOL
allow_partial
)
{
cookie_domain
*
searchDomain
;
...
...
@@ -242,18 +242,22 @@ static cookie_domain *COOKIE_findNextDomain(LPCSTR lpszCookieDomain, LPCSTR lpsz
if
(
candidate
&&
!
searchDomain
->
lpCookieDomain
)
candidate
=
FALSE
;
TRACE
(
"candidate! (%p)
\n
"
,
searchDomain
->
lpCookieDomain
);
TRACE
(
"comparing domain %s with %s
\n
"
,
lpszCookieDomain
,
searchDomain
->
lpCookieDomain
);
if
(
candidate
&&
allow_partial
&&
!
strstr
(
lpszCookieDomain
,
searchDomain
->
lpCookieDomain
))
TRACE
(
"comparing domain %s with %s
\n
"
,
debugstr_w
(
lpszCookieDomain
),
debugstr_w
(
searchDomain
->
lpCookieDomain
));
if
(
candidate
&&
allow_partial
&&
!
strstrW
(
lpszCookieDomain
,
searchDomain
->
lpCookieDomain
))
candidate
=
FALSE
;
else
if
(
candidate
&&
!
allow_partial
&&
strcmp
(
lpszCookieDomain
,
searchDomain
->
lpCookieDomain
)
!=
0
)
lstrcmpW
(
lpszCookieDomain
,
searchDomain
->
lpCookieDomain
)
!=
0
)
candidate
=
FALSE
;
}
if
(
candidate
&&
lpszCookiePath
)
{
TRACE
(
"comparing paths
\n
"
);
{
TRACE
(
"comparing paths
\n
"
);
if
(
candidate
&&
!
searchDomain
->
lpCookiePath
)
candidate
=
FALSE
;
if
(
candidate
&&
strcmp
(
lpszCookiePath
,
searchDomain
->
lpCookiePath
)
!=
0
)
if
(
candidate
&&
strcmpW
(
lpszCookiePath
,
searchDomain
->
lpCookiePath
))
candidate
=
FALSE
;
}
if
(
candidate
)
...
...
@@ -267,11 +271,11 @@ static cookie_domain *COOKIE_findNextDomain(LPCSTR lpszCookieDomain, LPCSTR lpsz
return
NULL
;
}
static
cookie_domain
*
COOKIE_findNextDomainFromUrl
(
LPCSTR
lpszUrl
,
cookie_domain
*
previous_domain
,
static
cookie_domain
*
COOKIE_findNextDomainFromUrl
(
LPC
W
STR
lpszUrl
,
cookie_domain
*
previous_domain
,
BOOL
allow_partial
)
{
char
hostName
[
2048
],
path
[
2048
];
URL_COMPONENTS
A
UrlComponents
;
WCHAR
hostName
[
2048
],
path
[
2048
];
URL_COMPONENTS
W
UrlComponents
;
UrlComponents
.
lpszExtraInfo
=
NULL
;
UrlComponents
.
lpszPassword
=
NULL
;
...
...
@@ -282,10 +286,11 @@ static cookie_domain *COOKIE_findNextDomainFromUrl(LPCSTR lpszUrl, cookie_domain
UrlComponents
.
dwHostNameLength
=
2048
;
UrlComponents
.
dwUrlPathLength
=
2048
;
InternetCrackUrl
A
(
lpszUrl
,
0
,
0
,
&
UrlComponents
);
InternetCrackUrl
W
(
lpszUrl
,
0
,
0
,
&
UrlComponents
);
TRACE
(
"Url cracked. Domain: %s, Path: %s.
\n
"
,
debugstr_a
(
UrlComponents
.
lpszHostName
),
debugstr_a
(
UrlComponents
.
lpszUrlPath
));
TRACE
(
"Url cracked. Domain: %s, Path: %s.
\n
"
,
debugstr_w
(
UrlComponents
.
lpszHostName
),
debugstr_w
(
UrlComponents
.
lpszUrlPath
));
/* hack for now - FIXME - There seems to be a bug in InternetCrackUrl?? */
UrlComponents
.
lpszUrlPath
=
NULL
;
...
...
@@ -314,7 +319,7 @@ static void COOKIE_deleteDomain(cookie_domain *deadDomain)
}
/***********************************************************************
* InternetGetCookie
A
(WININET.@)
* InternetGetCookie
W
(WININET.@)
*
* Retrieve cookie from the specified url
*
...
...
@@ -326,8 +331,8 @@ static void COOKIE_deleteDomain(cookie_domain *deadDomain)
* FALSE on failure
*
*/
BOOL
WINAPI
InternetGetCookie
A
(
LPCSTR
lpszUrl
,
LPC
STR
lpszCookieName
,
LPSTR
lpCookieData
,
LPDWORD
lpdwSize
)
BOOL
WINAPI
InternetGetCookie
W
(
LPCWSTR
lpszUrl
,
LPCW
STR
lpszCookieName
,
LP
W
STR
lpCookieData
,
LPDWORD
lpdwSize
)
{
cookie_domain
*
cookiesDomain
=
NULL
;
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
* 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
);
if
(
lpCookieData
)
cnt
+=
snprintf
(
lpCookieData
+
cnt
,
*
lpdwSize
-
cnt
,
"%s"
,
TrackingString
);
cnt
+=
snprintf
W
(
lpCookieData
+
cnt
,
*
lpdwSize
-
cnt
,
szps
,
TrackingString
);
else
cnt
+=
strlen
(
TrackingString
);
cnt
+=
strlen
W
(
TrackingString
);
while
((
cookiesDomain
=
COOKIE_findNextDomainFromUrl
(
lpszUrl
,
cookiesDomain
,
TRUE
)))
{
...
...
@@ -359,17 +368,20 @@ BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
while
(
thisCookie
)
{
cnt
+=
2
;
/* '; ' */
cnt
+=
strlen
(
thisCookie
->
lpCookieName
);
cnt
+=
strlen
W
(
thisCookie
->
lpCookieName
);
cnt
+=
1
;
/* = */
cnt
+=
strlen
(
thisCookie
->
lpCookieData
);
cnt
+=
strlen
W
(
thisCookie
->
lpCookieData
);
thisCookie
=
thisCookie
->
prev
;
}
}
while
(
thisCookie
)
{
cnt
+=
snprintf
(
lpCookieData
+
cnt
,
*
lpdwSize
-
cnt
,
"; "
);
cnt
+=
snprintf
(
lpCookieData
+
cnt
,
*
lpdwSize
-
cnt
,
"%s=%s"
,
thisCookie
->
lpCookieName
,
WCHAR
szsc
[]
=
{
';'
,
' '
,
0
};
WCHAR
szpseq
[]
=
{
'%'
,
's'
,
'='
,
'%'
,
's'
,
0
};
cnt
+=
snprintfW
(
lpCookieData
+
cnt
,
*
lpdwSize
-
cnt
,
szsc
);
cnt
+=
snprintfW
(
lpCookieData
+
cnt
,
*
lpdwSize
-
cnt
,
szpseq
,
thisCookie
->
lpCookieName
,
thisCookie
->
lpCookieData
);
thisCookie
=
thisCookie
->
prev
;
...
...
@@ -388,14 +400,15 @@ BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
*
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
);
}
/***********************************************************************
* InternetGetCookie
W
(WININET.@)
* InternetGetCookie
A
(WININET.@)
*
* Retrieve cookie from the specified url
*
...
...
@@ -404,18 +417,56 @@ BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
* FALSE on failure
*
*/
BOOL
WINAPI
InternetGetCookie
W
(
LPCWSTR
lpszUrl
,
LPCW
STR
lpszCookieName
,
LP
W
STR
lpCookieData
,
LPDWORD
lpdwSize
)
BOOL
WINAPI
InternetGetCookie
A
(
LPCSTR
lpszUrl
,
LPC
STR
lpszCookieName
,
LPSTR
lpCookieData
,
LPDWORD
lpdwSize
)
{
FIXME
(
"STUB
\n
"
);
TRACE
(
"(%s,%s,%p)
\n
"
,
debugstr_w
(
lpszUrl
),
debugstr_w
(
lpszCookieName
),
DWORD
len
;
LPWSTR
szCookieData
=
NULL
,
szUrl
=
NULL
,
szCookieName
=
NULL
;
BOOL
r
;
TRACE
(
"(%s,%s,%p)
\n
"
,
debugstr_a
(
lpszUrl
),
debugstr_a
(
lpszCookieName
),
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
);
}
r
=
InternetGetCookieW
(
szUrl
,
szCookieName
,
NULL
,
&
len
);
if
(
r
)
{
szCookieData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
)
);
if
(
!
szCookieData
)
return
FALSE
;
r
=
InternetGetCookieW
(
szUrl
,
szCookieName
,
szCookieData
,
&
len
);
*
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
;
}
/***********************************************************************
* InternetSetCookie
A
(WININET.@)
* InternetSetCookie
W
(WININET.@)
*
* Sets cookie for the specified url
*
...
...
@@ -424,16 +475,16 @@ BOOL WINAPI InternetGetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
* FALSE on failure
*
*/
BOOL
WINAPI
InternetSetCookie
A
(
LPCSTR
lpszUrl
,
LPC
STR
lpszCookieName
,
LPCSTR
lpCookieData
)
BOOL
WINAPI
InternetSetCookie
W
(
LPCWSTR
lpszUrl
,
LPCW
STR
lpszCookieName
,
LPC
W
STR
lpCookieData
)
{
cookie
*
thisCookie
;
cookie_domain
*
thisCookieDomain
;
TRACE
(
"(%s,%s,%s)
\n
"
,
debugstr_
a
(
lpszUrl
),
debugstr_
a
(
lpszCookieName
),
lpCookieData
);
TRACE
(
"(%s,%s,%s)
\n
"
,
debugstr_
w
(
lpszUrl
),
debugstr_
w
(
lpszCookieName
),
debugstr_w
(
lpCookieData
)
);
if
(
!
lpCookieData
||
!
strlen
(
lpCookieData
))
if
(
!
lpCookieData
||
!
strlen
W
(
lpCookieData
))
{
TRACE
(
"no cookie data, not adding
\n
"
);
return
FALSE
;
...
...
@@ -443,21 +494,24 @@ BOOL WINAPI InternetSetCookieA(LPCSTR lpszUrl, LPCSTR 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
;
WCHAR
*
ourCookieName
,
*
ourCookieData
;
int
ourCookieNameSize
;
BOOL
ret
;
if
(
!
(
ourCookieData
=
strchr
(
lpCookieData
,
'='
)))
if
(
!
(
ourCookieData
=
strchr
W
(
lpCookieData
,
'='
)))
{
TRACE
(
"something terribly wrong with cookie data %s
\n
"
,
ourCookieData
);
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
);
strncpy
(
ourCookieName
,
ourCookieData
,
ourCookieNameSize
);
ourCookieName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
ourCookieNameSize
+
1
)
*
sizeof
(
WCHAR
));
strncpyW
(
ourCookieName
,
ourCookieData
,
ourCookieNameSize
);
ourCookieName
[
ourCookieNameSize
]
=
'\0'
;
TRACE
(
"setting (hacked) cookie of %s, %s
\n
"
,
ourCookieName
,
ourCookieData
);
ret
=
InternetSetCookieA
(
lpszUrl
,
ourCookieName
,
ourCookieData
);
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
;
}
...
...
@@ -474,7 +528,7 @@ BOOL WINAPI InternetSetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
/***********************************************************************
* InternetSetCookie
W
(WININET.@)
* InternetSetCookie
A
(WININET.@)
*
* Sets cookie for the specified url
*
...
...
@@ -483,11 +537,45 @@ BOOL WINAPI InternetSetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
* FALSE on failure
*
*/
BOOL
WINAPI
InternetSetCookie
W
(
LPCWSTR
lpszUrl
,
LPCW
STR
lpszCookieName
,
LPC
W
STR
lpCookieData
)
BOOL
WINAPI
InternetSetCookie
A
(
LPCSTR
lpszUrl
,
LPC
STR
lpszCookieName
,
LPCSTR
lpCookieData
)
{
FIXME
(
"STUB
\n
"
);
TRACE
(
"(%s,%s,%s)
\n
"
,
debugstr_w
(
lpszUrl
),
debugstr_w
(
lpszCookieName
),
debugstr_w
(
lpCookieData
));
return
FALSE
;
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
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment