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
8ac9773e
Commit
8ac9773e
authored
Mar 03, 2004
by
Kevin Koltzau
Committed by
Alexandre Julliard
Mar 03, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix UrlCanonicalize and add regression test.
parent
2ab690bc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
4 deletions
+64
-4
path.c
dlls/shlwapi/tests/path.c
+57
-0
url.c
dlls/shlwapi/url.c
+7
-4
No files found.
dlls/shlwapi/tests/path.c
View file @
8ac9773e
...
...
@@ -34,6 +34,27 @@ const char* TEST_URL_1 = "http://www.winehq.org/tests?date=10/10/1923";
const
char
*
TEST_URL_2
=
"http://localhost:8080/tests%2e.html?date=Mon%2010/10/1923"
;
const
char
*
TEST_URL_3
=
"http://foo:bar@localhost:21/internal.php?query=x&return=y"
;
typedef
struct
_TEST_URL_CANONICALIZE
{
char
*
url
;
DWORD
flags
;
HRESULT
expectret
;
char
*
expecturl
;
}
TEST_URL_CANONICALIZE
;
const
TEST_URL_CANONICALIZE
TEST_CANONICALIZE
[]
=
{
{
"http://www.winehq.org/tests/../tests"
,
0
,
S_OK
,
"http://www.winehq.org/tests"
},
{
"http://www.winehq.org/tests/../tests/"
,
0
,
S_OK
,
"http://www.winehq.org/tests/"
},
{
"http://www.winehq.org/tests/../tests/.."
,
0
,
S_OK
,
"http://www.winehq.org/"
},
{
"http://www.winehq.org/tests/../tests/../"
,
0
,
S_OK
,
"http://www.winehq.org/"
},
{
"http://www.winehq.org/tests/.."
,
0
,
S_OK
,
"http://www.winehq.org/"
},
{
"http://www.winehq.org/tests/../"
,
0
,
S_OK
,
"http://www.winehq.org/"
},
{
"http://www.winehq.org/tests/..?query=x&return=y"
,
0
,
S_OK
,
"http://www.winehq.org/?query=x&return=y"
},
{
"http://www.winehq.org/tests/../?query=x&return=y"
,
0
,
S_OK
,
"http://www.winehq.org/?query=x&return=y"
},
{
"http://www.winehq.org/tests/..#example"
,
0
,
S_OK
,
"http://www.winehq.org/#example"
},
{
"http://www.winehq.org/tests/../#example"
,
0
,
S_OK
,
"http://www.winehq.org/#example"
},
{
"http://www.winehq.org/tests/../#example"
,
URL_DONT_SIMPLIFY
,
S_OK
,
"http://www.winehq.org/tests/../#example"
},
};
static
LPWSTR
GetWideString
(
const
char
*
szString
)
{
LPWSTR
wszString
=
(
LPWSTR
)
HeapAlloc
(
GetProcessHeap
(),
0
,
...
...
@@ -108,8 +129,44 @@ static void test_UrlGetPart(void)
test_url_part
(
TEST_URL_3
,
URL_PART_QUERY
,
0
,
"?query=x&return=y"
);
}
static
void
test_url_canonicalize
(
const
char
*
szUrl
,
DWORD
dwFlags
,
HRESULT
dwExpectReturn
,
const
char
*
szExpectUrl
)
{
CHAR
szReturnUrl
[
INTERNET_MAX_URL_LENGTH
];
WCHAR
wszReturnUrl
[
INTERNET_MAX_URL_LENGTH
];
LPWSTR
wszUrl
=
GetWideString
(
szUrl
);
LPWSTR
wszExpectUrl
=
GetWideString
(
szExpectUrl
);
LPWSTR
wszConvertedUrl
;
DWORD
dwSize
;
dwSize
=
INTERNET_MAX_URL_LENGTH
;
ok
(
UrlCanonicalizeA
(
szUrl
,
szReturnUrl
,
&
dwSize
,
dwFlags
)
==
dwExpectReturn
,
"UrlCanonicalizeA didn't return 0x%08lx
\n
"
,
dwExpectReturn
);
dwSize
=
INTERNET_MAX_URL_LENGTH
;
ok
(
UrlCanonicalizeW
(
wszUrl
,
wszReturnUrl
,
&
dwSize
,
dwFlags
)
==
dwExpectReturn
,
"UrlCanonicalizeW didn't return 0x%08lx
\n
"
,
dwExpectReturn
);
wszConvertedUrl
=
GetWideString
(
szReturnUrl
);
ok
(
strcmpW
(
wszReturnUrl
,
wszConvertedUrl
)
==
0
,
"Strings didn't match between ascii and unicode UrlCanonicalize!
\n
"
);
FreeWideString
(
wszConvertedUrl
);
ok
(
strcmp
(
szReturnUrl
,
szExpectUrl
)
==
0
,
"Expected %s, but got %s
\n
"
,
szExpectUrl
,
szReturnUrl
);
FreeWideString
(
wszUrl
);
FreeWideString
(
wszExpectUrl
);
}
static
void
test_UrlCanonicalize
(
void
)
{
int
i
;
for
(
i
=
0
;
i
<
sizeof
(
TEST_CANONICALIZE
)
/
sizeof
(
TEST_CANONICALIZE
[
0
]);
i
++
)
{
test_url_canonicalize
(
TEST_CANONICALIZE
[
i
].
url
,
TEST_CANONICALIZE
[
i
].
flags
,
TEST_CANONICALIZE
[
i
].
expectret
,
TEST_CANONICALIZE
[
i
].
expecturl
);
}
}
START_TEST
(
path
)
{
test_UrlHash
();
test_UrlGetPart
();
test_UrlCanonicalize
();
}
dlls/shlwapi/url.c
View file @
8ac9773e
...
...
@@ -514,8 +514,8 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
wk2
+=
strlenW
(
wk2
);
break
;
case
4
:
if
(
!
isalnumW
(
*
wk1
)
&&
(
*
wk1
!=
L'-'
))
{
state
=
3
;
break
;}
while
(
isalnumW
(
*
wk1
)
||
(
*
wk1
==
L'-'
))
*
wk2
++
=
*
wk1
++
;
if
(
!
isalnumW
(
*
wk1
)
&&
(
*
wk1
!=
L'-'
)
&&
(
*
wk1
!=
L'.'
)
)
{
state
=
3
;
break
;}
while
(
isalnumW
(
*
wk1
)
||
(
*
wk1
==
L'-'
)
||
(
*
wk1
==
L'.'
)
)
*
wk2
++
=
*
wk1
++
;
state
=
5
;
break
;
case
5
:
...
...
@@ -549,7 +549,7 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
else
if
(
*
(
wk1
+
1
)
==
L'.'
)
{
/* found /.. look for next / */
TRACE
(
"found '/..'
\n
"
);
if
(
*
(
wk1
+
2
)
==
L'/'
)
{
if
(
*
(
wk1
+
2
)
==
L'/'
||
*
(
wk1
+
2
)
==
L'?'
||
*
(
wk1
+
2
)
==
L'#'
||
*
(
wk1
+
2
)
==
0
)
{
/* case /../ -> need to backup wk2 */
TRACE
(
"found '/../'
\n
"
);
*
(
wk2
-
1
)
=
L'\0'
;
/* set end of string */
...
...
@@ -557,7 +557,10 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
if
(
mp
&&
(
mp
>=
root
))
{
/* found valid backup point */
wk2
=
mp
+
1
;
wk1
+=
3
;
if
(
*
(
wk1
+
2
)
!=
L'/'
)
wk1
+=
2
;
else
wk1
+=
3
;
}
else
{
/* did not find point, restore '/' */
...
...
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