Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
5ccfec64
Commit
5ccfec64
authored
Nov 14, 2007
by
Hans Leidekker
Committed by
Alexandre Julliard
Nov 15, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wininet: Fix a number of problems with InternetGetCookie.
This version incorporates Lei Zhang's changes to the test, with his consent.
parent
b6ee3c1d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
31 deletions
+44
-31
cookie.c
dlls/wininet/cookie.c
+30
-22
internet.c
dlls/wininet/tests/internet.c
+14
-9
No files found.
dlls/wininet/cookie.c
View file @
5ccfec64
...
@@ -258,21 +258,23 @@ static void COOKIE_deleteDomain(cookie_domain *deadDomain)
...
@@ -258,21 +258,23 @@ static void COOKIE_deleteDomain(cookie_domain *deadDomain)
BOOL
WINAPI
InternetGetCookieW
(
LPCWSTR
lpszUrl
,
LPCWSTR
lpszCookieName
,
BOOL
WINAPI
InternetGetCookieW
(
LPCWSTR
lpszUrl
,
LPCWSTR
lpszCookieName
,
LPWSTR
lpCookieData
,
LPDWORD
lpdwSize
)
LPWSTR
lpCookieData
,
LPDWORD
lpdwSize
)
{
{
BOOL
ret
;
struct
list
*
cursor
;
struct
list
*
cursor
;
int
cnt
=
0
,
domain_count
=
0
;
unsigned
int
cnt
=
0
,
domain_count
=
0
,
cookie_count
=
0
;
int
cookie_count
=
0
;
WCHAR
hostName
[
2048
],
path
[
2048
];
WCHAR
hostName
[
2048
],
path
[
2048
];
TRACE
(
"(%s, %s, %p, %p)
\n
"
,
debugstr_w
(
lpszUrl
),
debugstr_w
(
lpszCookieName
),
TRACE
(
"(%s, %s, %p, %p)
\n
"
,
debugstr_w
(
lpszUrl
),
debugstr_w
(
lpszCookieName
),
lpCookieData
,
lpdwSize
);
lpCookieData
,
lpdwSize
);
if
(
!
lpszUrl
)
if
(
!
lpszUrl
)
{
{
SetLastError
(
ERROR_IN
TERNET_UNRECOGNIZED_SCHEME
);
SetLastError
(
ERROR_IN
VALID_PARAMETER
);
return
FALSE
;
return
FALSE
;
}
}
COOKIE_crackUrlSimple
(
lpszUrl
,
hostName
,
sizeof
(
hostName
)
/
sizeof
(
hostName
[
0
]),
path
,
sizeof
(
path
)
/
sizeof
(
path
[
0
]));
hostName
[
0
]
=
0
;
ret
=
COOKIE_crackUrlSimple
(
lpszUrl
,
hostName
,
sizeof
(
hostName
)
/
sizeof
(
hostName
[
0
]),
path
,
sizeof
(
path
)
/
sizeof
(
path
[
0
]));
if
(
!
ret
||
!
hostName
[
0
])
return
FALSE
;
LIST_FOR_EACH
(
cursor
,
&
domain_list
)
LIST_FOR_EACH
(
cursor
,
&
domain_list
)
{
{
...
@@ -288,22 +290,29 @@ BOOL WINAPI InternetGetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
...
@@ -288,22 +290,29 @@ BOOL WINAPI InternetGetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
cookie
*
thisCookie
=
LIST_ENTRY
(
cursor
,
cookie
,
entry
);
cookie
*
thisCookie
=
LIST_ENTRY
(
cursor
,
cookie
,
entry
);
if
(
lpCookieData
==
NULL
)
/* return the size of the buffer required to lpdwSize */
if
(
lpCookieData
==
NULL
)
/* return the size of the buffer required to lpdwSize */
{
{
if
(
cookie_count
!=
0
)
unsigned
int
len
;
cnt
+=
2
;
/* '; ' */
if
(
cookie_count
)
cnt
+=
2
;
/* '; ' */
cnt
+=
strlenW
(
thisCookie
->
lpCookieName
);
cnt
+=
strlenW
(
thisCookie
->
lpCookieName
);
cnt
+=
1
;
/* = */
if
((
len
=
strlenW
(
thisCookie
->
lpCookieData
)))
cnt
+=
strlenW
(
thisCookie
->
lpCookieData
);
{
cnt
+=
1
;
/* = */
cnt
+=
len
;
}
}
}
else
else
{
{
static
const
WCHAR
szsc
[]
=
{
';'
,
' '
,
0
};
static
const
WCHAR
szsc
[]
=
{
';'
,
' '
,
0
};
static
const
WCHAR
szpseq
[]
=
{
'%'
,
's'
,
'='
,
'%'
,
's'
,
0
};
static
const
WCHAR
szname
[]
=
{
'%'
,
's'
,
0
};
if
(
cookie_count
!=
0
)
static
const
WCHAR
szdata
[]
=
{
'='
,
'%'
,
's'
,
0
};
cnt
+=
snprintfW
(
lpCookieData
+
cnt
,
*
lpdwSize
-
cnt
,
szsc
);
cnt
+=
snprintfW
(
lpCookieData
+
cnt
,
*
lpdwSize
-
cnt
,
szpseq
,
if
(
cookie_count
)
cnt
+=
snprintfW
(
lpCookieData
+
cnt
,
*
lpdwSize
-
cnt
,
szsc
);
thisCookie
->
lpCookieName
,
cnt
+=
snprintfW
(
lpCookieData
+
cnt
,
*
lpdwSize
-
cnt
,
szname
,
thisCookie
->
lpCookieName
);
thisCookie
->
lpCookieData
);
TRACE
(
"Cookie: %s=%s
\n
"
,
debugstr_w
(
thisCookie
->
lpCookieName
),
debugstr_w
(
thisCookie
->
lpCookieData
));
if
(
thisCookie
->
lpCookieData
[
0
])
cnt
+=
snprintfW
(
lpCookieData
+
cnt
,
*
lpdwSize
-
cnt
,
szdata
,
thisCookie
->
lpCookieData
);
TRACE
(
"Cookie: %s
\n
"
,
debugstr_w
(
lpCookieData
));
}
}
cookie_count
++
;
cookie_count
++
;
}
}
...
@@ -319,15 +328,14 @@ BOOL WINAPI InternetGetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
...
@@ -319,15 +328,14 @@ BOOL WINAPI InternetGetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
if
(
lpCookieData
==
NULL
)
if
(
lpCookieData
==
NULL
)
{
{
cnt
+=
1
;
/* NULL */
*
lpdwSize
=
(
cnt
+
1
)
*
sizeof
(
WCHAR
);
*
lpdwSize
=
cnt
*
sizeof
(
WCHAR
);
TRACE
(
"returning %u
\n
"
,
*
lpdwSize
);
TRACE
(
"returning
\n
"
);
return
TRUE
;
return
TRUE
;
}
}
*
lpdwSize
=
(
cnt
+
1
)
*
sizeof
(
WCHAR
)
;
*
lpdwSize
=
cnt
+
1
;
TRACE
(
"Returning %
i (from %i
domains): %s
\n
"
,
cnt
,
domain_count
,
TRACE
(
"Returning %
u (from %u
domains): %s
\n
"
,
cnt
,
domain_count
,
debugstr_w
(
lpCookieData
));
debugstr_w
(
lpCookieData
));
return
(
cnt
?
TRUE
:
FALSE
);
return
(
cnt
?
TRUE
:
FALSE
);
...
...
dlls/wininet/tests/internet.c
View file @
5ccfec64
...
@@ -285,7 +285,7 @@ static void test_null(void)
...
@@ -285,7 +285,7 @@ static void test_null(void)
sz
=
0
;
sz
=
0
;
r
=
InternetGetCookieW
(
NULL
,
NULL
,
NULL
,
&
sz
);
r
=
InternetGetCookieW
(
NULL
,
NULL
,
NULL
,
&
sz
);
ok
(
GetLastError
()
==
ERROR_IN
TERNET_UNRECOGNIZED_SCHEME
,
"wrong error
\n
"
);
ok
(
GetLastError
()
==
ERROR_IN
VALID_PARAMETER
,
"wrong error
\n
"
);
ok
(
r
==
FALSE
,
"return wrong
\n
"
);
ok
(
r
==
FALSE
,
"return wrong
\n
"
);
r
=
InternetGetCookieW
(
szServer
,
NULL
,
NULL
,
&
sz
);
r
=
InternetGetCookieW
(
szServer
,
NULL
,
NULL
,
&
sz
);
...
@@ -295,25 +295,30 @@ static void test_null(void)
...
@@ -295,25 +295,30 @@ static void test_null(void)
ok
(
r
==
FALSE
,
"return wrong
\n
"
);
ok
(
r
==
FALSE
,
"return wrong
\n
"
);
sz
=
0
;
sz
=
0
;
r
=
InternetGetCookieW
(
szUrlEmpty
,
szServer
,
NULL
,
&
sz
);
ok
(
r
==
FALSE
,
"return wrong
\n
"
);
sz
=
0
;
r
=
InternetGetCookieW
(
szUrl
,
szServer
,
NULL
,
&
sz
);
r
=
InternetGetCookieW
(
szUrl
,
szServer
,
NULL
,
&
sz
);
ok
(
r
==
TRUE
,
"return wrong
\n
"
);
ok
(
r
==
TRUE
,
"return wrong
\n
"
);
todo_wine
{
ok
(
sz
==
30
,
"sz wrong
\n
"
);
/* sz is 14 on XP SP2 and beyond, 30 on XP SP1 and before */
}
ok
(
sz
==
14
||
sz
==
30
,
"sz wrong, got %u, expected 14 or 30
\n
"
,
sz
);
sz
=
0x20
;
sz
=
0x20
;
memset
(
buffer
,
0
,
sizeof
buffer
);
memset
(
buffer
,
0
,
sizeof
buffer
);
r
=
InternetGetCookieW
(
szUrl
,
szServer
,
buffer
,
&
sz
);
r
=
InternetGetCookieW
(
szUrl
,
szServer
,
buffer
,
&
sz
);
ok
(
r
==
TRUE
,
"return wrong
\n
"
);
ok
(
r
==
TRUE
,
"return wrong
\n
"
);
todo_wine
{
ok
(
sz
==
lstrlenW
(
buffer
),
"sz wrong
\n
"
);
/* sz == lstrlenW(buffer) only in XP SP1 */
ok
(
!
lstrcmpW
(
szExpect
,
buffer
),
"cookie data wrong
\n
"
);
ok
(
sz
==
1
+
lstrlenW
(
buffer
),
"sz wrong
\n
"
);
}
/* before XP SP2, buffer is "server; server" */
ok
(
!
lstrcmpW
(
szExpect
,
buffer
)
||
!
lstrcmpW
(
szServer
,
buffer
),
"cookie data wrong
\n
"
);
sz
=
sizeof
(
buffer
);
sz
=
sizeof
(
buffer
);
r
=
InternetQueryOptionA
(
NULL
,
INTERNET_OPTION_CONNECTED_STATE
,
buffer
,
&
sz
);
r
=
InternetQueryOptionA
(
NULL
,
INTERNET_OPTION_CONNECTED_STATE
,
buffer
,
&
sz
);
ok
(
r
==
TRUE
,
"ret %d
\n
"
,
r
);
ok
(
r
==
TRUE
,
"ret %d
\n
"
,
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