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
8b7fae35
Commit
8b7fae35
authored
Sep 05, 2010
by
Piotr Caban
Committed by
Alexandre Julliard
Sep 07, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shlwapi: Improved UrlCanonicalize implementation.
parent
a1fecdaf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
9 deletions
+31
-9
url.c
dlls/shlwapi/tests/url.c
+2
-0
url.c
dlls/shlwapi/url.c
+29
-9
No files found.
dlls/shlwapi/tests/url.c
View file @
8b7fae35
...
...
@@ -114,6 +114,7 @@ static const TEST_URL_CANONICALIZE TEST_CANONICALIZE[] = {
{
"http://www.winehq.org/tests/../"
,
0
,
S_OK
,
"http://www.winehq.org/"
,
FALSE
},
{
"http://www.winehq.org/tests/..?query=x&return=y"
,
0
,
S_OK
,
"http://www.winehq.org/?query=x&return=y"
,
FALSE
},
{
"http://www.winehq.org/tests/../?query=x&return=y"
,
0
,
S_OK
,
"http://www.winehq.org/?query=x&return=y"
,
FALSE
},
{
"
\t
ht
\t
tp
\t
://www
\t
.w
\t
ineh
\t\t
q.or
\t
g
\t
/
\t
tests/..
\t
?
\t
quer
\t
y=x
\t\t
&re
\t
turn=y
\t\t
"
,
0
,
S_OK
,
"http://www.winehq.org/?query=x&return=y"
,
FALSE
},
{
"http://www.winehq.org/tests/..#example"
,
0
,
S_OK
,
"http://www.winehq.org/#example"
,
FALSE
},
{
"http://www.winehq.org/tests/../#example"
,
0
,
S_OK
,
"http://www.winehq.org/#example"
,
FALSE
},
{
"http://www.winehq.org/tests
\\
../#example"
,
0
,
S_OK
,
"http://www.winehq.org/#example"
,
FALSE
},
...
...
@@ -143,6 +144,7 @@ static const TEST_URL_CANONICALIZE TEST_CANONICALIZE[] = {
{
"c:dir
\\
file"
,
0
,
S_OK
,
"file:///c:dir/file"
,
FALSE
},
{
"c:
\\
tests
\\
foo bar"
,
URL_FILE_USE_PATHURL
,
S_OK
,
"file://c:
\\
tests
\\
foo bar"
,
FALSE
},
{
"c:
\\
tests
\\
foo bar"
,
0
,
S_OK
,
"file:///c:/tests/foo%20bar"
,
FALSE
},
{
"c
\t
:
\t\\
te
\t
sts
\\
fo
\t
o
\t
bar
\t
"
,
0
,
S_OK
,
"file:///c:/tests/foo%20bar"
,
FALSE
},
{
"res://file"
,
0
,
S_OK
,
"res://file/"
,
FALSE
},
{
"res://file"
,
URL_FILE_USE_PATHURL
,
S_OK
,
"res://file/"
,
FALSE
},
{
"res:///c:/tests/foo%20bar"
,
URL_UNESCAPE
,
S_OK
,
"res:///c:/tests/foo bar"
,
FALSE
},
...
...
dlls/shlwapi/url.c
View file @
8b7fae35
...
...
@@ -273,7 +273,7 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
HRESULT
hr
=
S_OK
;
DWORD
EscapeFlags
;
LPCWSTR
wk1
,
root
;
LPWSTR
lpszUrlCpy
,
wk2
,
mp
,
mp2
;
LPWSTR
lpszUrlCpy
,
url
,
wk2
,
mp
,
mp2
;
INT
state
;
DWORD
nByteLen
,
nLen
,
nWkLen
;
WCHAR
slash
=
'\0'
;
...
...
@@ -295,22 +295,40 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
return
S_OK
;
}
/* Remove '\t' characters from URL */
nByteLen
=
(
strlenW
(
pszUrl
)
+
1
)
*
sizeof
(
WCHAR
);
/* length in bytes */
url
=
HeapAlloc
(
GetProcessHeap
(),
0
,
nByteLen
);
if
(
!
url
)
return
E_OUTOFMEMORY
;
wk1
=
pszUrl
;
wk2
=
url
;
do
{
while
(
*
wk1
==
'\t'
)
wk1
++
;
*
wk2
++
=
*
wk1
;
}
while
(
*
wk1
++
);
/* Allocate memory for simplified URL (before escaping) */
nByteLen
=
(
wk2
-
url
)
*
sizeof
(
WCHAR
);
lpszUrlCpy
=
HeapAlloc
(
GetProcessHeap
(),
0
,
nByteLen
+
sizeof
(
wszFilePrefix
)
+
sizeof
(
WCHAR
));
if
(
!
lpszUrlCpy
)
{
HeapFree
(
GetProcessHeap
(),
0
,
url
);
return
E_OUTOFMEMORY
;
}
if
((
nByteLen
>=
sizeof
(
wszHttp
)
&&
!
memcmp
(
wszHttp
,
pszU
rl
,
sizeof
(
wszHttp
)))
||
!
memcmp
(
wszHttp
,
u
rl
,
sizeof
(
wszHttp
)))
||
(
nByteLen
>=
sizeof
(
wszFile
)
&&
!
memcmp
(
wszFile
,
pszU
rl
,
sizeof
(
wszFile
))))
!
memcmp
(
wszFile
,
u
rl
,
sizeof
(
wszFile
))))
slash
=
'/'
;
if
((
dwFlags
&
URL_FILE_USE_PATHURL
)
&&
nByteLen
>=
sizeof
(
wszFile
)
&&
!
memcmp
(
wszFile
,
pszU
rl
,
sizeof
(
wszFile
)))
&&
!
memcmp
(
wszFile
,
u
rl
,
sizeof
(
wszFile
)))
slash
=
'\\'
;
if
(
nByteLen
>=
sizeof
(
wszRes
)
&&
!
memcmp
(
wszRes
,
pszU
rl
,
sizeof
(
wszRes
)))
{
if
(
nByteLen
>=
sizeof
(
wszRes
)
&&
!
memcmp
(
wszRes
,
u
rl
,
sizeof
(
wszRes
)))
{
dwFlags
&=
~
URL_FILE_USE_PATHURL
;
slash
=
'\0'
;
}
...
...
@@ -326,11 +344,11 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
* 6 have location (found /) save root location
*/
wk1
=
pszU
rl
;
wk1
=
u
rl
;
wk2
=
lpszUrlCpy
;
state
=
0
;
if
(
pszU
rl
[
1
]
==
':'
)
{
/* Assume path */
if
(
u
rl
[
1
]
==
':'
)
{
/* Assume path */
memcpy
(
wk2
,
wszFilePrefix
,
sizeof
(
wszFilePrefix
));
wk2
+=
sizeof
(
wszFilePrefix
)
/
sizeof
(
WCHAR
);
if
(
dwFlags
&
URL_FILE_USE_PATHURL
)
...
...
@@ -361,7 +379,7 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
if
(
*
wk1
!=
'/'
)
{
state
=
6
;
break
;}
*
wk2
++
=
*
wk1
++
;
if
((
dwFlags
&
URL_FILE_USE_PATHURL
)
&&
nByteLen
>=
sizeof
(
wszLocalhost
)
&&
!
strncmpW
(
wszFile
,
pszU
rl
,
sizeof
(
wszFile
)
/
sizeof
(
WCHAR
))
&&
!
strncmpW
(
wszFile
,
u
rl
,
sizeof
(
wszFile
)
/
sizeof
(
WCHAR
))
&&
!
memcmp
(
wszLocalhost
,
wk1
,
sizeof
(
wszLocalhost
))){
wk1
+=
sizeof
(
wszLocalhost
)
/
sizeof
(
WCHAR
);
while
(
*
wk1
==
'\\'
&&
(
dwFlags
&
URL_FILE_USE_PATHURL
))
...
...
@@ -483,6 +501,7 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
default:
FIXME
(
"how did we get here - state=%d
\n
"
,
state
);
HeapFree
(
GetProcessHeap
(),
0
,
lpszUrlCpy
);
HeapFree
(
GetProcessHeap
(),
0
,
url
);
return
E_INVALIDARG
;
}
*
wk2
=
'\0'
;
...
...
@@ -495,7 +514,7 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
if
((
dwFlags
&
URL_UNESCAPE
)
||
((
dwFlags
&
URL_FILE_USE_PATHURL
)
&&
nByteLen
>=
sizeof
(
wszFile
)
&&
!
memcmp
(
wszFile
,
pszU
rl
,
sizeof
(
wszFile
))))
&&
!
memcmp
(
wszFile
,
u
rl
,
sizeof
(
wszFile
))))
UrlUnescapeW
(
lpszUrlCpy
,
NULL
,
&
nLen
,
URL_UNESCAPE_INPLACE
);
if
((
EscapeFlags
=
dwFlags
&
(
URL_ESCAPE_UNSAFE
|
...
...
@@ -518,6 +537,7 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
}
HeapFree
(
GetProcessHeap
(),
0
,
lpszUrlCpy
);
HeapFree
(
GetProcessHeap
(),
0
,
url
);
if
(
hr
==
S_OK
)
TRACE
(
"result %s
\n
"
,
debugstr_w
(
pszCanonicalized
));
...
...
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