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
0b64d319
Commit
0b64d319
authored
Jul 29, 2012
by
Alex Henrie
Committed by
Alexandre Julliard
Jul 31, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wininet: Support ICU_ENCODE_PERCENT, ICU_ENCODE_SPACES_ONLY, and ICU_NO_META.
parent
882977ee
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
60 deletions
+75
-60
internet.c
dlls/wininet/internet.c
+32
-60
url.c
dlls/wininet/tests/url.c
+42
-0
wininet.h
include/wininet.h
+1
-0
No files found.
dlls/wininet/internet.c
View file @
0b64d319
...
...
@@ -1963,6 +1963,32 @@ DWORD WINAPI InternetAttemptConnect(DWORD dwReserved)
/***********************************************************************
* convert_url_canonicalization_flags
*
* Helper for InternetCanonicalizeUrl
*
* PARAMS
* dwFlags [I] Flags suitable for InternetCanonicalizeUrl
*
* RETURNS
* Flags suitable for UrlCanonicalize
*/
static
DWORD
convert_url_canonicalization_flags
(
DWORD
dwFlags
)
{
DWORD
dwUrlFlags
=
URL_WININET_COMPATIBILITY
|
URL_ESCAPE_UNSAFE
;
if
(
dwFlags
&
ICU_BROWSER_MODE
)
dwUrlFlags
|=
URL_BROWSER_MODE
;
if
(
dwFlags
&
ICU_DECODE
)
dwUrlFlags
|=
URL_UNESCAPE
;
if
(
dwFlags
&
ICU_ENCODE_PERCENT
)
dwUrlFlags
|=
URL_ESCAPE_PERCENT
;
if
(
dwFlags
&
ICU_ENCODE_SPACES_ONLY
)
dwUrlFlags
|=
URL_ESCAPE_SPACES_ONLY
;
/* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
if
(
dwFlags
&
ICU_NO_ENCODE
)
dwUrlFlags
^=
URL_ESCAPE_UNSAFE
;
if
(
dwFlags
&
ICU_NO_META
)
dwUrlFlags
|=
URL_NO_META
;
return
dwUrlFlags
;
}
/***********************************************************************
* InternetCanonicalizeUrlA (WININET.@)
*
* Escape unsafe characters and spaces
...
...
@@ -1976,43 +2002,16 @@ BOOL WINAPI InternetCanonicalizeUrlA(LPCSTR lpszUrl, LPSTR lpszBuffer,
LPDWORD
lpdwBufferLength
,
DWORD
dwFlags
)
{
HRESULT
hr
;
DWORD
dwURLFlags
=
URL_WININET_COMPATIBILITY
|
URL_ESCAPE_UNSAFE
;
TRACE
(
"(%s, %p, %p, 0x%08x) bufferlength: %d
\n
"
,
debugstr_a
(
lpszUrl
),
lpszBuffer
,
lpdwBufferLength
,
dwFlags
,
lpdwBufferLength
?
*
lpdwBufferLength
:
-
1
);
if
(
dwFlags
&
ICU_DECODE
)
{
dwURLFlags
|=
URL_UNESCAPE
;
dwFlags
&=
~
ICU_DECODE
;
}
if
(
dwFlags
&
ICU_ESCAPE
)
{
dwURLFlags
|=
URL_UNESCAPE
;
dwFlags
&=
~
ICU_ESCAPE
;
}
if
(
dwFlags
&
ICU_BROWSER_MODE
)
{
dwURLFlags
|=
URL_BROWSER_MODE
;
dwFlags
&=
~
ICU_BROWSER_MODE
;
}
if
(
dwFlags
&
ICU_NO_ENCODE
)
{
/* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
dwURLFlags
^=
URL_ESCAPE_UNSAFE
;
dwFlags
&=
~
ICU_NO_ENCODE
;
}
if
(
dwFlags
)
FIXME
(
"Unhandled flags 0x%08x
\n
"
,
dwFlags
);
hr
=
UrlCanonicalizeA
(
lpszUrl
,
lpszBuffer
,
lpdwBufferLength
,
dwURLFlags
);
dwFlags
=
convert_url_canonicalization_flags
(
dwFlags
);
hr
=
UrlCanonicalizeA
(
lpszUrl
,
lpszBuffer
,
lpdwBufferLength
,
dwFlags
);
if
(
hr
==
E_POINTER
)
SetLastError
(
ERROR_INSUFFICIENT_BUFFER
);
if
(
hr
==
E_INVALIDARG
)
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
(
hr
==
S_OK
)
?
TRUE
:
FALSE
;
return
hr
==
S_OK
;
}
/***********************************************************************
...
...
@@ -2029,43 +2028,16 @@ BOOL WINAPI InternetCanonicalizeUrlW(LPCWSTR lpszUrl, LPWSTR lpszBuffer,
LPDWORD
lpdwBufferLength
,
DWORD
dwFlags
)
{
HRESULT
hr
;
DWORD
dwURLFlags
=
URL_WININET_COMPATIBILITY
|
URL_ESCAPE_UNSAFE
;
TRACE
(
"(%s, %p, %p, 0x%08x) bufferlength: %d
\n
"
,
debugstr_w
(
lpszUrl
),
lpszBuffer
,
lpdwBufferLength
,
dwFlags
,
lpdwBufferLength
?
*
lpdwBufferLength
:
-
1
);
if
(
dwFlags
&
ICU_DECODE
)
{
dwURLFlags
|=
URL_UNESCAPE
;
dwFlags
&=
~
ICU_DECODE
;
}
if
(
dwFlags
&
ICU_ESCAPE
)
{
dwURLFlags
|=
URL_UNESCAPE
;
dwFlags
&=
~
ICU_ESCAPE
;
}
if
(
dwFlags
&
ICU_BROWSER_MODE
)
{
dwURLFlags
|=
URL_BROWSER_MODE
;
dwFlags
&=
~
ICU_BROWSER_MODE
;
}
if
(
dwFlags
&
ICU_NO_ENCODE
)
{
/* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
dwURLFlags
^=
URL_ESCAPE_UNSAFE
;
dwFlags
&=
~
ICU_NO_ENCODE
;
}
if
(
dwFlags
)
FIXME
(
"Unhandled flags 0x%08x
\n
"
,
dwFlags
);
hr
=
UrlCanonicalizeW
(
lpszUrl
,
lpszBuffer
,
lpdwBufferLength
,
dwURLFlags
);
dwFlags
=
convert_url_canonicalization_flags
(
dwFlags
);
hr
=
UrlCanonicalizeW
(
lpszUrl
,
lpszBuffer
,
lpdwBufferLength
,
dwFlags
);
if
(
hr
==
E_POINTER
)
SetLastError
(
ERROR_INSUFFICIENT_BUFFER
);
if
(
hr
==
E_INVALIDARG
)
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
(
hr
==
S_OK
)
?
TRUE
:
FALSE
;
return
hr
==
S_OK
;
}
/* #################################################### */
...
...
dlls/wininet/tests/url.c
View file @
0b64d319
...
...
@@ -1098,6 +1098,47 @@ static void InternetCreateUrlA_test(void)
HeapFree
(
GetProcessHeap
(),
0
,
szUrl
);
}
static
void
InternetCanonicalizeUrl_test
(
void
)
{
char
src
[]
=
"http://www.winehq.org/%27/ /./>/#> "
;
char
dst
[
64
];
DWORD
dstlen
;
dstlen
=
sizeof
(
dst
);
InternetCanonicalizeUrlA
(
src
,
dst
,
&
dstlen
,
0
);
ok
(
strcmp
(
dst
,
"http://www.winehq.org/%27/%20/%3E/#>"
)
==
0
,
"Got
\"
%s
\"\n
"
,
dst
);
/* despite what MSDN says, ICU_BROWSER_MODE seems to be ignored */
dstlen
=
sizeof
(
dst
);
InternetCanonicalizeUrlA
(
src
,
dst
,
&
dstlen
,
ICU_BROWSER_MODE
);
ok
(
strcmp
(
dst
,
"http://www.winehq.org/%27/%20/%3E/#>"
)
==
0
,
"Got
\"
%s
\"\n
"
,
dst
);
/* ICU_ESCAPE is supposed to be ignored */
dstlen
=
sizeof
(
dst
);
InternetCanonicalizeUrlA
(
src
,
dst
,
&
dstlen
,
ICU_ESCAPE
);
ok
(
strcmp
(
dst
,
"http://www.winehq.org/%27/%20/%3E/#>"
)
==
0
,
"Got
\"
%s
\"\n
"
,
dst
);
dstlen
=
sizeof
(
dst
);
InternetCanonicalizeUrlA
(
src
,
dst
,
&
dstlen
,
ICU_DECODE
);
ok
(
strcmp
(
dst
,
"http://www.winehq.org/'/%20/%3E/#>"
)
==
0
,
"Got
\"
%s
\"\n
"
,
dst
);
dstlen
=
sizeof
(
dst
);
InternetCanonicalizeUrlA
(
src
,
dst
,
&
dstlen
,
ICU_ENCODE_PERCENT
);
ok
(
strcmp
(
dst
,
"http://www.winehq.org/%2527/%20/%3E/#>"
)
==
0
,
"Got
\"
%s
\"\n
"
,
dst
);
dstlen
=
sizeof
(
dst
);
InternetCanonicalizeUrlA
(
src
,
dst
,
&
dstlen
,
ICU_ENCODE_SPACES_ONLY
);
ok
(
strcmp
(
dst
,
"http://www.winehq.org/%27/%20/>/#>"
)
==
0
,
"Got
\"
%s
\"\n
"
,
dst
);
dstlen
=
sizeof
(
dst
);
InternetCanonicalizeUrlA
(
src
,
dst
,
&
dstlen
,
ICU_NO_ENCODE
);
ok
(
strcmp
(
dst
,
"http://www.winehq.org/%27/ />/#>"
)
==
0
,
"Got
\"
%s
\"\n
"
,
dst
);
dstlen
=
sizeof
(
dst
);
InternetCanonicalizeUrlA
(
src
,
dst
,
&
dstlen
,
ICU_NO_META
);
ok
(
strcmp
(
dst
,
"http://www.winehq.org/%27/%20/./%3E/#>"
)
==
0
,
"Got
\"
%s
\"\n
"
,
dst
);
}
START_TEST
(
url
)
{
int
i
;
...
...
@@ -1113,4 +1154,5 @@ START_TEST(url)
InternetCrackUrl_test
();
InternetCrackUrlW_test
();
InternetCreateUrlA_test
();
InternetCanonicalizeUrl_test
();
}
include/wininet.h
View file @
0b64d319
...
...
@@ -421,6 +421,7 @@ BOOLAPI InternetCombineUrlW(LPCWSTR ,LPCWSTR ,LPWSTR ,LPDWORD ,DWORD);
#define ICU_NO_META 0x08000000
#define ICU_ENCODE_SPACES_ONLY 0x04000000
#define ICU_BROWSER_MODE 0x02000000
#define ICU_ENCODE_PERCENT 0x00001000
INTERNETAPI
HINTERNET
WINAPI
InternetOpenA
(
LPCSTR
,
DWORD
,
LPCSTR
,
LPCSTR
,
DWORD
);
INTERNETAPI
HINTERNET
WINAPI
InternetOpenW
(
LPCWSTR
,
DWORD
,
LPCWSTR
,
LPCWSTR
,
DWORD
);
...
...
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