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
462b2feb
Commit
462b2feb
authored
Apr 18, 2014
by
Nikolay Sivov
Committed by
Alexandre Julliard
Apr 18, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shlwapi: Fix UrlEscapeW() for non-ASCII range.
parent
389992fd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
97 deletions
+97
-97
url.c
dlls/shlwapi/tests/url.c
+67
-53
url.c
dlls/shlwapi/url.c
+30
-44
No files found.
dlls/shlwapi/tests/url.c
View file @
462b2feb
...
...
@@ -297,7 +297,9 @@ static const TEST_URL_ESCAPE TEST_ESCAPE[] = {
{
"ftp://fo/o@bar.baz/fo#o
\\
bar"
,
0
,
0
,
S_OK
,
"ftp://fo/o@bar.baz/fo#o
\\
bar"
},
{
"ftp://localhost/o@bar.baz/fo#o
\\
bar"
,
0
,
0
,
S_OK
,
"ftp://localhost/o@bar.baz/fo#o
\\
bar"
},
{
"ftp:///fo/o@bar.baz/foo/bar"
,
0
,
0
,
S_OK
,
"ftp:///fo/o@bar.baz/foo/bar"
},
{
"ftp:////fo/o@bar.baz/foo/bar"
,
0
,
0
,
S_OK
,
"ftp:////fo/o@bar.baz/foo/bar"
}
{
"ftp:////fo/o@bar.baz/foo/bar"
,
0
,
0
,
S_OK
,
"ftp:////fo/o@bar.baz/foo/bar"
},
{
"ftp
\x1f\1
end/"
,
0
,
0
,
S_OK
,
"ftp%1F%01end/"
}
};
/* ################ */
...
...
@@ -779,34 +781,6 @@ static void test_UrlGetPart(void)
}
/* ########################### */
static
void
test_url_escape
(
const
char
*
szUrl
,
DWORD
dwFlags
,
HRESULT
dwExpectReturn
,
const
char
*
szExpectUrl
)
{
CHAR
szReturnUrl
[
INTERNET_MAX_URL_LENGTH
];
DWORD
dwEscaped
;
WCHAR
ret_urlW
[
INTERNET_MAX_URL_LENGTH
];
WCHAR
*
urlW
,
*
expected_urlW
;
dwEscaped
=
INTERNET_MAX_URL_LENGTH
;
ok
(
pUrlEscapeA
(
szUrl
,
szReturnUrl
,
&
dwEscaped
,
dwFlags
)
==
dwExpectReturn
,
"UrlEscapeA didn't return 0x%08x from
\"
%s
\"\n
"
,
dwExpectReturn
,
szUrl
);
ok
(
strcmp
(
szReturnUrl
,
szExpectUrl
)
==
0
,
"Expected
\"
%s
\"
, but got
\"
%s
\"
from
\"
%s
\"\n
"
,
szExpectUrl
,
szReturnUrl
,
szUrl
);
if
(
pUrlEscapeW
)
{
dwEscaped
=
INTERNET_MAX_URL_LENGTH
;
urlW
=
GetWideString
(
szUrl
);
expected_urlW
=
GetWideString
(
szExpectUrl
);
ok
(
pUrlEscapeW
(
urlW
,
ret_urlW
,
&
dwEscaped
,
dwFlags
)
==
dwExpectReturn
,
"UrlEscapeW didn't return 0x%08x from
\"
%s
\"\n
"
,
dwExpectReturn
,
szUrl
);
WideCharToMultiByte
(
CP_ACP
,
0
,
ret_urlW
,
-
1
,
szReturnUrl
,
INTERNET_MAX_URL_LENGTH
,
0
,
0
);
ok
(
lstrcmpW
(
ret_urlW
,
expected_urlW
)
==
0
,
"Expected
\"
%s
\"
, but got
\"
%s
\"
from
\"
%s
\"
flags %08x
\n
"
,
szExpectUrl
,
szReturnUrl
,
szUrl
,
dwFlags
);
FreeWideString
(
urlW
);
FreeWideString
(
expected_urlW
);
}
}
static
void
test_url_canonicalize
(
int
index
,
const
char
*
szUrl
,
DWORD
dwFlags
,
HRESULT
dwExpectReturn
,
HRESULT
dwExpectReturnAlt
,
const
char
*
szExpectUrl
,
BOOL
todo
)
{
CHAR
szReturnUrl
[
INTERNET_MAX_URL_LENGTH
];
...
...
@@ -850,18 +824,15 @@ static void test_url_canonicalize(int index, const char *szUrl, DWORD dwFlags, H
}
static
void
test_UrlEscape
(
void
)
static
void
test_UrlEscape
A
(
void
)
{
static
const
WCHAR
out
[]
=
{
'f'
,
'o'
,
'o'
,
'%'
,
'2'
,
'0'
,
'b'
,
'a'
,
'r'
,
0
};
DWORD
size
=
0
;
HRESULT
ret
;
unsigned
int
i
;
char
empty_string
[]
=
""
;
WCHAR
overwrite
[]
=
{
'f'
,
'o'
,
'o'
,
' '
,
'b'
,
'a'
,
'r'
,
0
,
0
,
0
};
if
(
!
pUrlEscapeA
)
{
win_skip
(
"UrlEscapeA no
z
found
\n
"
);
win_skip
(
"UrlEscapeA no
t
found
\n
"
);
return
;
}
...
...
@@ -891,26 +862,68 @@ static void test_UrlEscape(void)
ok
(
size
==
34
,
"got %d, expected %d
\n
"
,
size
,
34
);
ok
(
empty_string
[
0
]
==
127
,
"String has changed, empty_string[0] = %d
\n
"
,
empty_string
[
0
]);
if
(
pUrlEscapeW
)
{
WCHAR
wc
;
size
=
sizeof
(
overwrite
)
/
sizeof
(
WCHAR
);
ret
=
pUrlEscapeW
(
overwrite
,
overwrite
,
&
size
,
URL_ESCAPE_SPACES_ONLY
);
ok
(
ret
==
S_OK
,
"got %x, expected S_OK
\n
"
,
ret
);
ok
(
size
==
9
,
"got %d, expected 9
\n
"
,
size
);
ok
(
!
lstrcmpW
(
overwrite
,
out
),
"got %s, expected %s
\n
"
,
wine_dbgstr_w
(
overwrite
),
wine_dbgstr_w
(
out
));
size
=
1
;
wc
=
127
;
ret
=
pUrlEscapeW
(
overwrite
,
&
wc
,
&
size
,
URL_ESCAPE_SPACES_ONLY
);
ok
(
ret
==
E_POINTER
,
"got %x, expected %x
\n
"
,
ret
,
E_POINTER
);
ok
(
size
==
10
,
"got %d, expected 10
\n
"
,
size
);
ok
(
wc
==
127
,
"String has changed, wc = %d
\n
"
,
wc
);
for
(
i
=
0
;
i
<
sizeof
(
TEST_ESCAPE
)
/
sizeof
(
TEST_ESCAPE
[
0
]);
i
++
)
{
CHAR
ret_url
[
INTERNET_MAX_URL_LENGTH
];
size
=
INTERNET_MAX_URL_LENGTH
;
ret
=
pUrlEscapeA
(
TEST_ESCAPE
[
i
].
url
,
ret_url
,
&
size
,
TEST_ESCAPE
[
i
].
flags
);
ok
(
ret
==
TEST_ESCAPE
[
i
].
expectret
,
"UrlEscapeA returned 0x%08x instead of 0x%08x for
\"
%s
\"\n
"
,
ret
,
TEST_ESCAPE
[
i
].
expectret
,
TEST_ESCAPE
[
i
].
url
);
ok
(
!
strcmp
(
ret_url
,
TEST_ESCAPE
[
i
].
expecturl
),
"Expected
\"
%s
\"
, but got
\"
%s
\"
for
\"
%s
\"\n
"
,
TEST_ESCAPE
[
i
].
expecturl
,
ret_url
,
TEST_ESCAPE
[
i
].
url
);
}
}
static
void
test_UrlEscapeW
(
void
)
{
static
const
WCHAR
naW
[]
=
{
'f'
,
't'
,
'p'
,
31
,
255
,
250
,
0x2122
,
'e'
,
'n'
,
'd'
,
'/'
,
0
};
static
const
WCHAR
naescapedW
[]
=
{
'f'
,
't'
,
'p'
,
'%'
,
'1'
,
'F'
,
'%'
,
'F'
,
'F'
,
'%'
,
'F'
,
'A'
,
0x2122
,
'e'
,
'n'
,
'd'
,
'/'
,
0
};
static
const
WCHAR
out
[]
=
{
'f'
,
'o'
,
'o'
,
'%'
,
'2'
,
'0'
,
'b'
,
'a'
,
'r'
,
0
};
WCHAR
overwrite
[]
=
{
'f'
,
'o'
,
'o'
,
' '
,
'b'
,
'a'
,
'r'
,
0
,
0
,
0
};
WCHAR
ret_urlW
[
INTERNET_MAX_URL_LENGTH
];
DWORD
size
=
0
;
HRESULT
ret
;
WCHAR
wc
;
int
i
;
if
(
!
pUrlEscapeW
)
{
win_skip
(
"UrlEscapeW not found
\n
"
);
return
;
}
for
(
i
=
0
;
i
<
sizeof
(
TEST_ESCAPE
)
/
sizeof
(
TEST_ESCAPE
[
0
]);
i
++
)
{
test_url_escape
(
TEST_ESCAPE
[
i
].
url
,
TEST_ESCAPE
[
i
].
flags
,
TEST_ESCAPE
[
i
].
expectret
,
TEST_ESCAPE
[
i
].
expecturl
);
size
=
sizeof
(
overwrite
)
/
sizeof
(
WCHAR
);
ret
=
pUrlEscapeW
(
overwrite
,
overwrite
,
&
size
,
URL_ESCAPE_SPACES_ONLY
);
ok
(
ret
==
S_OK
,
"got %x, expected S_OK
\n
"
,
ret
);
ok
(
size
==
9
,
"got %d, expected 9
\n
"
,
size
);
ok
(
!
lstrcmpW
(
overwrite
,
out
),
"got %s, expected %s
\n
"
,
wine_dbgstr_w
(
overwrite
),
wine_dbgstr_w
(
out
));
size
=
1
;
wc
=
127
;
ret
=
pUrlEscapeW
(
overwrite
,
&
wc
,
&
size
,
URL_ESCAPE_SPACES_ONLY
);
ok
(
ret
==
E_POINTER
,
"got %x, expected %x
\n
"
,
ret
,
E_POINTER
);
ok
(
size
==
10
,
"got %d, expected 10
\n
"
,
size
);
ok
(
wc
==
127
,
"String has changed, wc = %d
\n
"
,
wc
);
/* non-ASCII range */
size
=
sizeof
(
ret_urlW
)
/
sizeof
(
WCHAR
);
ret
=
pUrlEscapeW
(
naW
,
ret_urlW
,
&
size
,
0
);
ok
(
ret
==
S_OK
,
"got %x, expected S_OK
\n
"
,
ret
);
ok
(
!
lstrcmpW
(
naescapedW
,
ret_urlW
),
"got %s, expected %s
\n
"
,
wine_dbgstr_w
(
ret_urlW
),
wine_dbgstr_w
(
naescapedW
));
for
(
i
=
0
;
i
<
sizeof
(
TEST_ESCAPE
)
/
sizeof
(
TEST_ESCAPE
[
0
]);
i
++
)
{
WCHAR
*
urlW
,
*
expected_urlW
;
size
=
INTERNET_MAX_URL_LENGTH
;
urlW
=
GetWideString
(
TEST_ESCAPE
[
i
].
url
);
expected_urlW
=
GetWideString
(
TEST_ESCAPE
[
i
].
expecturl
);
ret
=
pUrlEscapeW
(
urlW
,
ret_urlW
,
&
size
,
TEST_ESCAPE
[
i
].
flags
);
ok
(
ret
==
TEST_ESCAPE
[
i
].
expectret
,
"UrlEscapeW returned 0x%08x instead of 0x%08x for %s
\n
"
,
ret
,
TEST_ESCAPE
[
i
].
expectret
,
wine_dbgstr_w
(
urlW
));
ok
(
!
lstrcmpW
(
ret_urlW
,
expected_urlW
),
"Expected %s, but got %s for %s flags %08x
\n
"
,
wine_dbgstr_w
(
expected_urlW
),
wine_dbgstr_w
(
ret_urlW
),
wine_dbgstr_w
(
urlW
),
TEST_ESCAPE
[
i
].
flags
);
FreeWideString
(
urlW
);
FreeWideString
(
expected_urlW
);
}
}
...
...
@@ -1548,7 +1561,8 @@ START_TEST(url)
test_UrlGetPart
();
test_UrlCanonicalizeA
();
test_UrlCanonicalizeW
();
test_UrlEscape
();
test_UrlEscapeA
();
test_UrlEscapeW
();
test_UrlCombine
();
test_UrlCreateFromPath
();
test_UrlIs
();
...
...
dlls/shlwapi/url.c
View file @
462b2feb
...
...
@@ -986,57 +986,43 @@ HRESULT WINAPI UrlEscapeA(
#define WINE_URL_STOP_ON_HASH 0x20
#define WINE_URL_STOP_ON_QUESTION 0x40
static
inline
BOOL
URL_NeedEscapeW
(
WCHAR
ch
,
DWORD
dwF
lags
,
DWORD
int_flags
)
static
inline
BOOL
URL_NeedEscapeW
(
WCHAR
ch
,
DWORD
f
lags
,
DWORD
int_flags
)
{
if
(
flags
&
URL_ESCAPE_SPACES_ONLY
)
return
ch
==
' '
;
if
(
isalnumW
(
ch
))
return
FALSE
;
if
(
dwFlags
&
URL_ESCAPE_SPACES_ONLY
)
{
if
(
ch
==
' '
)
return
TRUE
;
else
return
FALSE
;
}
if
((
dwFlags
&
URL_ESCAPE_PERCENT
)
&&
(
ch
==
'%'
))
if
((
flags
&
URL_ESCAPE_PERCENT
)
&&
(
ch
==
'%'
))
return
TRUE
;
if
(
ch
<=
31
||
ch
>=
127
)
if
(
ch
<=
31
||
(
ch
>=
127
&&
ch
<=
255
)
)
return
TRUE
;
else
{
switch
(
ch
)
{
case
' '
:
case
'<'
:
case
'>'
:
case
'\"'
:
case
'{'
:
case
'}'
:
case
'|'
:
case
'\\'
:
case
'^'
:
case
']'
:
case
'['
:
case
'`'
:
case
'&'
:
return
TRUE
;
case
'/'
:
if
(
int_flags
&
WINE_URL_ESCAPE_SLASH
)
return
TRUE
;
return
FALSE
;
case
'?'
:
if
(
int_flags
&
WINE_URL_ESCAPE_QUESTION
)
return
TRUE
;
return
FALSE
;
case
'#'
:
if
(
int_flags
&
WINE_URL_ESCAPE_HASH
)
return
TRUE
;
return
FALSE
;
if
(
isalnumW
(
ch
))
return
FALSE
;
default:
return
FALSE
;
}
switch
(
ch
)
{
case
' '
:
case
'<'
:
case
'>'
:
case
'\"'
:
case
'{'
:
case
'}'
:
case
'|'
:
case
'\\'
:
case
'^'
:
case
']'
:
case
'['
:
case
'`'
:
case
'&'
:
return
TRUE
;
case
'/'
:
return
!!
(
int_flags
&
WINE_URL_ESCAPE_SLASH
);
case
'?'
:
return
!!
(
int_flags
&
WINE_URL_ESCAPE_QUESTION
);
case
'#'
:
return
!!
(
int_flags
&
WINE_URL_ESCAPE_HASH
);
default:
return
FALSE
;
}
}
...
...
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