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
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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
48 deletions
+61
-48
cookie.c
dlls/wininet/cookie.c
+57
-46
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)
...
@@ -174,7 +174,7 @@ static cookie_domain *COOKIE_addDomain(LPCWSTR domain, LPCWSTR path)
return
newDomain
;
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
;
URL_COMPONENTSW
UrlComponents
;
...
@@ -191,7 +191,7 @@ static void COOKIE_crackUrlSimple(LPCWSTR lpszUrl, LPWSTR hostName, int hostName
...
@@ -191,7 +191,7 @@ static void COOKIE_crackUrlSimple(LPCWSTR lpszUrl, LPWSTR hostName, int hostName
UrlComponents
.
dwHostNameLength
=
hostNameLen
;
UrlComponents
.
dwHostNameLength
=
hostNameLen
;
UrlComponents
.
dwUrlPathLength
=
pathLen
;
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 */
/* 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,
...
@@ -392,6 +392,34 @@ BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
return
r
;
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.@)
* InternetSetCookieW (WININET.@)
...
@@ -406,64 +434,47 @@ BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
...
@@ -406,64 +434,47 @@ BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
BOOL
WINAPI
InternetSetCookieW
(
LPCWSTR
lpszUrl
,
LPCWSTR
lpszCookieName
,
BOOL
WINAPI
InternetSetCookieW
(
LPCWSTR
lpszUrl
,
LPCWSTR
lpszCookieName
,
LPCWSTR
lpCookieData
)
LPCWSTR
lpCookieData
)
{
{
cookie_domain
*
thisCookieDomain
=
NULL
;
BOOL
ret
;
cookie
*
thisCookie
;
WCHAR
hostName
[
2048
],
path
[
2048
];
WCHAR
hostName
[
2048
],
path
[
2048
];
struct
list
*
cursor
;
TRACE
(
"(%s,%s,%s)
\n
"
,
debugstr_w
(
lpszUrl
),
TRACE
(
"(%s,%s,%s)
\n
"
,
debugstr_w
(
lpszUrl
),
debugstr_w
(
lpszCookieName
),
debugstr_w
(
lpCookieData
));
debugstr_w
(
lpszCookieName
),
debugstr_w
(
lpCookieData
));
if
(
!
lpCookieData
)
if
(
!
lp
szUrl
||
!
lp
CookieData
)
{
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
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
)
if
(
!
lpszCookieName
)
{
{
/* some apps (or is it us??) try to add a cookie with no cookie name, but
unsigned
int
len
;
* the cookie data in the form of name=data. */
WCHAR
*
cookie
,
*
data
;
/* FIXME, probably a bug here, for now I don't care */
WCHAR
*
ourCookieName
,
*
ourCookieData
;
int
ourCookieNameSize
;
BOOL
ret
;
if
(
!
(
ourCookieData
=
strchrW
(
lpCookieData
,
'='
)))
{
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
)
*
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
]));
len
=
strlenW
(
lpCookieData
);
if
(
!
(
cookie
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
len
+
1
)
*
sizeof
(
WCHAR
))))
{
SetLastError
(
ERROR_OUTOFMEMORY
);
return
FALSE
;
}
strcpyW
(
cookie
,
lpCookieData
);
LIST_FOR_EACH
(
cursor
,
&
domain_list
)
/* 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].
thisCookieDomain
=
LIST_ENTRY
(
cursor
,
cookie_domain
,
entry
);
*/
if
(
COOKIE_matchDomain
(
hostName
,
NULL
/* FIXME: path */
,
thisCookieDomain
,
FALSE
))
if
(
!
(
data
=
strchrW
(
cookie
,
'='
)))
data
=
cookie
+
len
;
break
;
else
data
++
;
thisCookieDomain
=
NULL
;
}
if
(
!
thisCookieDomain
)
thisCookieDomain
=
COOKIE_addDomain
(
hostName
,
path
);
if
((
thisCookie
=
COOKIE_findCookie
(
thisCookieDomain
,
lpszCookieName
)))
ret
=
set_cookie
(
hostName
,
path
,
cookie
,
data
);
COOKIE_deleteCookie
(
thisCookie
,
FALSE
);
thisCookie
=
COOKIE_addCookie
(
thisCookieDomain
,
lpszCookieName
,
lpCookieData
);
HeapFree
(
GetProcessHeap
(),
0
,
cookie
);
return
TRUE
;
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)
...
@@ -218,6 +218,7 @@ static void test_null(void)
static
const
WCHAR
szServer
[]
=
{
's'
,
'e'
,
'r'
,
'v'
,
'e'
,
'r'
,
0
};
static
const
WCHAR
szServer
[]
=
{
's'
,
'e'
,
'r'
,
'v'
,
'e'
,
'r'
,
0
};
static
const
WCHAR
szEmpty
[]
=
{
0
};
static
const
WCHAR
szEmpty
[]
=
{
0
};
static
const
WCHAR
szUrl
[]
=
{
'h'
,
't'
,
't'
,
'p'
,
':'
,
'/'
,
'/'
,
'a'
,
'.'
,
'b'
,
'.'
,
'c'
,
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
};
static
const
WCHAR
szExpect
[]
=
{
's'
,
'e'
,
'r'
,
'v'
,
'e'
,
'r'
,
';'
,
' '
,
's'
,
'e'
,
'r'
,
'v'
,
'e'
,
'r'
,
0
};
WCHAR
buffer
[
0x20
];
WCHAR
buffer
[
0x20
];
BOOL
r
;
BOOL
r
;
...
@@ -267,14 +268,15 @@ static void test_null(void)
...
@@ -267,14 +268,15 @@ static void test_null(void)
r
=
InternetSetCookieW
(
szUrl
,
szServer
,
szServer
);
r
=
InternetSetCookieW
(
szUrl
,
szServer
,
szServer
);
ok
(
r
==
TRUE
,
"return wrong
\n
"
);
ok
(
r
==
TRUE
,
"return wrong
\n
"
);
todo_wine
{
r
=
InternetSetCookieW
(
szUrl
,
NULL
,
szServer
);
r
=
InternetSetCookieW
(
szUrl
,
NULL
,
szServer
);
ok
(
r
==
TRUE
,
"return wrong
\n
"
);
ok
(
r
==
TRUE
,
"return wrong
\n
"
);
}
r
=
InternetSetCookieW
(
szUrl
,
szServer
,
szEmpty
);
r
=
InternetSetCookieW
(
szUrl
,
szServer
,
szEmpty
);
ok
(
r
==
TRUE
,
"return wrong
\n
"
);
ok
(
r
==
TRUE
,
"return wrong
\n
"
);
r
=
InternetSetCookieW
(
szUrlEmpty
,
szServer
,
szServer
);
ok
(
r
==
FALSE
,
"return wrong
\n
"
);
r
=
InternetSetCookieW
(
szServer
,
NULL
,
szServer
);
r
=
InternetSetCookieW
(
szServer
,
NULL
,
szServer
);
todo_wine
{
todo_wine
{
ok
(
GetLastError
()
==
ERROR_INTERNET_UNRECOGNIZED_SCHEME
,
"wrong error
\n
"
);
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