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
b6ee3c1d
Commit
b6ee3c1d
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 InternetSetCookie.
parent
306129c9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
44 deletions
+57
-44
cookie.c
dlls/wininet/cookie.c
+53
-42
internet.c
dlls/wininet/tests/internet.c
+4
-2
No files found.
dlls/wininet/cookie.c
View file @
b6ee3c1d
...
...
@@ -174,7 +174,7 @@ static cookie_domain *COOKIE_addDomain(LPCWSTR domain, LPCWSTR path)
return
newDomain
;
}
static
void
COOKIE_crackUrlSimple
(
LPCWSTR
lpszUrl
,
LPWSTR
hostName
,
int
hostNameLen
,
LPWSTR
path
,
int
pathLen
)
static
BOOL
COOKIE_crackUrlSimple
(
LPCWSTR
lpszUrl
,
LPWSTR
hostName
,
int
hostNameLen
,
LPWSTR
path
,
int
pathLen
)
{
URL_COMPONENTSW
UrlComponents
;
...
...
@@ -191,7 +191,7 @@ static void COOKIE_crackUrlSimple(LPCWSTR lpszUrl, LPWSTR hostName, int hostName
UrlComponents
.
dwHostNameLength
=
hostNameLen
;
UrlComponents
.
dwUrlPathLength
=
pathLen
;
InternetCrackUrlW
(
lpszUrl
,
0
,
0
,
&
UrlComponents
);
return
InternetCrackUrlW
(
lpszUrl
,
0
,
0
,
&
UrlComponents
);
}
/* match a domain. domain must match if the domain is not NULL. path must match if the path is not NULL */
...
...
@@ -392,6 +392,34 @@ BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
return
r
;
}
static
BOOL
set_cookie
(
LPCWSTR
domain
,
LPCWSTR
path
,
LPCWSTR
cookie_name
,
LPCWSTR
cookie_data
)
{
cookie_domain
*
thisCookieDomain
=
NULL
;
cookie
*
thisCookie
;
struct
list
*
cursor
;
LIST_FOR_EACH
(
cursor
,
&
domain_list
)
{
thisCookieDomain
=
LIST_ENTRY
(
cursor
,
cookie_domain
,
entry
);
if
(
COOKIE_matchDomain
(
domain
,
NULL
/* FIXME: path */
,
thisCookieDomain
,
FALSE
))
break
;
thisCookieDomain
=
NULL
;
}
if
(
!
thisCookieDomain
)
thisCookieDomain
=
COOKIE_addDomain
(
domain
,
path
);
if
((
thisCookie
=
COOKIE_findCookie
(
thisCookieDomain
,
cookie_name
)))
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
));
if
(
!
COOKIE_addCookie
(
thisCookieDomain
,
cookie_name
,
cookie_data
))
return
FALSE
;
return
TRUE
;
}
/***********************************************************************
* InternetSetCookieW (WININET.@)
...
...
@@ -406,64 +434,47 @@ BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
BOOL
WINAPI
InternetSetCookieW
(
LPCWSTR
lpszUrl
,
LPCWSTR
lpszCookieName
,
LPCWSTR
lpCookieData
)
{
cookie_domain
*
thisCookieDomain
=
NULL
;
cookie
*
thisCookie
;
BOOL
ret
;
WCHAR
hostName
[
2048
],
path
[
2048
];
struct
list
*
cursor
;
TRACE
(
"(%s,%s,%s)
\n
"
,
debugstr_w
(
lpszUrl
),
debugstr_w
(
lpszCookieName
),
debugstr_w
(
lpCookieData
));
if
(
!
lpCookieData
)
if
(
!
lp
szUrl
||
!
lp
CookieData
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
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
;
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
;
unsigned
int
len
;
WCHAR
*
cookie
,
*
data
;
if
(
!
(
ourCookieData
=
strchrW
(
lpCookieData
,
'='
)))
len
=
strlenW
(
lpCookieData
);
if
(
!
(
cookie
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
len
+
1
)
*
sizeof
(
WCHAR
))))
{
TRACE
(
"something terribly wrong with cookie data %s
\n
"
,
debugstr_w
(
ourCookieData
));
SetLastError
(
ERROR_OUTOFMEMORY
);
return
FALSE
;
}
ourCookieNameSize
=
ourCookieData
-
lpCookieData
;
ourCookieData
+=
1
;
ourCookieName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
ourCookieNameSize
+
1
)
*
sizeof
(
WCHAR
));
memcpy
(
ourCookieName
,
lpCookieData
,
ourCookieNameSize
*
sizeof
(
WCHAR
));
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
;
}
COOKIE_crackUrlSimple
(
lpszUrl
,
hostName
,
sizeof
(
hostName
)
/
sizeof
(
hostName
[
0
]),
path
,
sizeof
(
path
)
/
sizeof
(
path
[
0
]));
strcpyW
(
cookie
,
lpCookieData
);
LIST_FOR_EACH
(
cursor
,
&
domain_list
)
{
thisCookieDomain
=
LIST_ENTRY
(
cursor
,
cookie_domain
,
entry
);
if
(
COOKIE_matchDomain
(
hostName
,
NULL
/* FIXME: path */
,
thisCookieDomain
,
FALSE
))
break
;
thisCookieDomain
=
NULL
;
}
if
(
!
thisCookieDomain
)
thisCookieDomain
=
COOKIE_addDomain
(
hostName
,
path
);
/* 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].
*/
if
(
!
(
data
=
strchrW
(
cookie
,
'='
)))
data
=
cookie
+
len
;
else
data
++
;
if
((
thisCookie
=
COOKIE_findCookie
(
thisCookieDomain
,
lpszCookieName
)))
COOKIE_deleteCookie
(
thisCookie
,
FALSE
);
ret
=
set_cookie
(
hostName
,
path
,
cookie
,
data
);
thisCookie
=
COOKIE_addCookie
(
thisCookieDomain
,
lpszCookieName
,
lpCookieData
);
return
TRUE
;
HeapFree
(
GetProcessHeap
(),
0
,
cookie
);
return
ret
;
}
return
set_cookie
(
hostName
,
path
,
lpszCookieName
,
lpCookieData
);
}
...
...
dlls/wininet/tests/internet.c
View file @
b6ee3c1d
...
...
@@ -218,6 +218,7 @@ static void test_null(void)
static
const
WCHAR
szServer
[]
=
{
's'
,
'e'
,
'r'
,
'v'
,
'e'
,
'r'
,
0
};
static
const
WCHAR
szEmpty
[]
=
{
0
};
static
const
WCHAR
szUrl
[]
=
{
'h'
,
't'
,
't'
,
'p'
,
':'
,
'/'
,
'/'
,
'a'
,
'.'
,
'b'
,
'.'
,
'c'
,
0
};
static
const
WCHAR
szUrlEmpty
[]
=
{
'h'
,
't'
,
't'
,
'p'
,
':'
,
'/'
,
'/'
,
0
};
static
const
WCHAR
szExpect
[]
=
{
's'
,
'e'
,
'r'
,
'v'
,
'e'
,
'r'
,
';'
,
' '
,
's'
,
'e'
,
'r'
,
'v'
,
'e'
,
'r'
,
0
};
WCHAR
buffer
[
0x20
];
BOOL
r
;
...
...
@@ -267,14 +268,15 @@ static void test_null(void)
r
=
InternetSetCookieW
(
szUrl
,
szServer
,
szServer
);
ok
(
r
==
TRUE
,
"return wrong
\n
"
);
todo_wine
{
r
=
InternetSetCookieW
(
szUrl
,
NULL
,
szServer
);
ok
(
r
==
TRUE
,
"return wrong
\n
"
);
}
r
=
InternetSetCookieW
(
szUrl
,
szServer
,
szEmpty
);
ok
(
r
==
TRUE
,
"return wrong
\n
"
);
r
=
InternetSetCookieW
(
szUrlEmpty
,
szServer
,
szServer
);
ok
(
r
==
FALSE
,
"return wrong
\n
"
);
r
=
InternetSetCookieW
(
szServer
,
NULL
,
szServer
);
todo_wine
{
ok
(
GetLastError
()
==
ERROR_INTERNET_UNRECOGNIZED_SCHEME
,
"wrong error
\n
"
);
...
...
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