1 /* Unit test suite for Path functions
3 * Copyright 2002 Matthew Mastracci
4 * Copyright 2007-2010 Detlef Riekenberg
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/test.h"
33 static const char* TEST_URL_1
= "http://www.winehq.org/tests?date=10/10/1923";
34 static const char* TEST_URL_2
= "http://localhost:8080/tests%2e.html?date=Mon%2010/10/1923";
35 static const char* TEST_URL_3
= "http://foo:bar@localhost:21/internal.php?query=x&return=y";
37 static const WCHAR winehqW
[] = L
"http://www.winehq.org/";
38 static const char winehqA
[] = "http://www.winehq.org/";
39 static const CHAR untouchedA
[] = "untouched";
41 typedef struct _TEST_URL_APPLY
{
48 static const TEST_URL_APPLY TEST_APPLY
[] = {
49 {"www.winehq.org", URL_APPLY_GUESSSCHEME
| URL_APPLY_DEFAULT
, S_OK
, "http://www.winehq.org"},
50 {"www.winehq.org", URL_APPLY_GUESSSCHEME
, S_OK
, "http://www.winehq.org"},
51 {"www.winehq.org", URL_APPLY_DEFAULT
, S_OK
, "http://www.winehq.org"},
52 {"ftp.winehq.org", URL_APPLY_GUESSSCHEME
| URL_APPLY_DEFAULT
, S_OK
, "ftp://ftp.winehq.org"},
53 {"ftp.winehq.org", URL_APPLY_GUESSSCHEME
, S_OK
, "ftp://ftp.winehq.org"},
54 {"ftp.winehq.org", URL_APPLY_DEFAULT
, S_OK
, "http://ftp.winehq.org"},
55 {"winehq.org", URL_APPLY_GUESSSCHEME
| URL_APPLY_DEFAULT
, S_OK
, "http://winehq.org"},
56 {"winehq.org", URL_APPLY_GUESSSCHEME
, S_FALSE
},
57 {"winehq.org", URL_APPLY_DEFAULT
, S_OK
, "http://winehq.org"},
58 {"http://www.winehq.org", URL_APPLY_GUESSSCHEME
, S_FALSE
},
59 {"http://www.winehq.org", URL_APPLY_GUESSSCHEME
| URL_APPLY_FORCEAPPLY
, S_FALSE
},
60 {"http://www.winehq.org", URL_APPLY_GUESSSCHEME
| URL_APPLY_FORCEAPPLY
| URL_APPLY_DEFAULT
, S_OK
, "http://http://www.winehq.org"},
61 {"http://www.winehq.org", URL_APPLY_GUESSSCHEME
| URL_APPLY_DEFAULT
, S_FALSE
},
62 {"", URL_APPLY_GUESSSCHEME
| URL_APPLY_DEFAULT
, S_OK
, "http://"},
63 {"", URL_APPLY_GUESSSCHEME
, S_FALSE
},
64 {"", URL_APPLY_DEFAULT
, S_OK
, "http://"},
65 {"u:\\windows", URL_APPLY_GUESSFILE
| URL_APPLY_DEFAULT
, S_OK
, "file:///u:/windows"},
66 {"u:\\windows", URL_APPLY_GUESSFILE
, S_OK
, "file:///u:/windows"},
67 {"u:\\windows", URL_APPLY_DEFAULT
, S_OK
, "http://u:\\windows"},
68 {"file:///c:/windows", URL_APPLY_GUESSFILE
, S_FALSE
},
69 {"aa:\\windows", URL_APPLY_GUESSFILE
, S_FALSE
},
70 {"\\\\server\\share", URL_APPLY_DEFAULT
, S_OK
, "http://\\\\server\\share"},
71 {"\\\\server\\share", URL_APPLY_GUESSFILE
, S_OK
, "file://server/share"},
72 {"\\\\server\\share", URL_APPLY_GUESSSCHEME
, S_FALSE
},
73 {"file://server/share", URL_APPLY_GUESSFILE
, S_FALSE
},
74 {"file://server/share", URL_APPLY_GUESSSCHEME
, S_FALSE
},
77 typedef struct _TEST_URL_ESCAPE
{
80 const char *expecturl
;
83 static const TEST_URL_ESCAPE TEST_ESCAPE
[] = {
84 {"http://www.winehq.org/tests0", 0, "http://www.winehq.org/tests0"},
85 {"http://www.winehq.org/tests1\n", 0, "http://www.winehq.org/tests1%0A"},
86 {"http://www.winehq.org/tests2\r", 0, "http://www.winehq.org/tests2%0D"},
87 {"http://www.winehq.org/tests3\r", URL_ESCAPE_SPACES_ONLY
|URL_ESCAPE_UNSAFE
, "http://www.winehq.org/tests3\r"},
88 {"http://www.winehq.org/tests4\r", URL_ESCAPE_SPACES_ONLY
, "http://www.winehq.org/tests4\r"},
89 {"http://www.winehq.org/tests5\r", URL_WININET_COMPATIBILITY
|URL_ESCAPE_SPACES_ONLY
, "http://www.winehq.org/tests5\r"},
90 {"/direct/swhelp/series6/6.2i_latestservicepack.dat\r", URL_ESCAPE_SPACES_ONLY
, "/direct/swhelp/series6/6.2i_latestservicepack.dat\r"},
92 {"file://////foo/bar\\baz", 0, "file://foo/bar/baz"},
93 {"file://///foo/bar\\baz", 0, "file://foo/bar/baz"},
94 {"file:////foo/bar\\baz", 0, "file://foo/bar/baz"},
95 {"file:///localhost/foo/bar\\baz", 0, "file:///localhost/foo/bar/baz"},
96 {"file:///foo/bar\\baz", 0, "file:///foo/bar/baz"},
97 {"file://loCalHost/foo/bar\\baz", 0, "file:///foo/bar/baz"},
98 {"file://foo/bar\\baz", 0, "file://foo/bar/baz"},
99 {"file:/localhost/foo/bar\\baz", 0, "file:///localhost/foo/bar/baz"},
100 {"file:/foo/bar\\baz", 0, "file:///foo/bar/baz"},
101 {"file:foo/bar\\baz", 0, "file:foo/bar/baz"},
102 {"file:\\foo/bar\\baz", 0, "file:///foo/bar/baz"},
103 {"file:\\\\foo/bar\\baz", 0, "file://foo/bar/baz"},
104 {"file:\\\\\\foo/bar\\baz", 0, "file:///foo/bar/baz"},
105 {"file:\\\\localhost\\foo/bar\\baz", 0, "file:///foo/bar/baz"},
106 {"file:///f oo/b?a r\\baz", 0, "file:///f%20oo/b?a r\\baz"},
107 {"file:///foo/b#a r\\baz", 0, "file:///foo/b%23a%20r/baz"},
108 {"file:///f o^&`{}|][\"<>\\%o/b#a r\\baz", 0, "file:///f%20o%5E%26%60%7B%7D%7C%5D%5B%22%3C%3E/%o/b%23a%20r/baz"},
109 {"file:///f o%o/b?a r\\b%az", URL_ESCAPE_PERCENT
, "file:///f%20o%25o/b?a r\\b%az"},
110 {"file:/foo/bar\\baz", URL_ESCAPE_SEGMENT_ONLY
, "file:%2Ffoo%2Fbar%5Cbaz"},
112 {"foo/b%ar\\ba?z\\", URL_ESCAPE_SEGMENT_ONLY
, "foo%2Fb%ar%5Cba%3Fz%5C"},
113 {"foo/b%ar\\ba?z\\", URL_ESCAPE_PERCENT
| URL_ESCAPE_SEGMENT_ONLY
, "foo%2Fb%25ar%5Cba%3Fz%5C"},
114 {"foo/bar\\ba?z\\", 0, "foo/bar%5Cba?z\\"},
115 {"/foo/bar\\ba?z\\", 0, "/foo/bar%5Cba?z\\"},
116 {"/foo/bar\\ba#z\\", 0, "/foo/bar%5Cba#z\\"},
117 {"/foo/%5C", 0, "/foo/%5C"},
118 {"/foo/%5C", URL_ESCAPE_PERCENT
, "/foo/%255C"},
120 {"http://////foo/bar\\baz", 0, "http://////foo/bar/baz"},
121 {"http://///foo/bar\\baz", 0, "http://///foo/bar/baz"},
122 {"http:////foo/bar\\baz", 0, "http:////foo/bar/baz"},
123 {"http:///foo/bar\\baz", 0, "http:///foo/bar/baz"},
124 {"http://localhost/foo/bar\\baz", 0, "http://localhost/foo/bar/baz"},
125 {"http://foo/bar\\baz", 0, "http://foo/bar/baz"},
126 {"http:/foo/bar\\baz", 0, "http:/foo/bar/baz"},
127 {"http:foo/bar\\ba?z\\", 0, "http:foo%2Fbar%2Fba?z\\"},
128 {"http:foo/bar\\ba#z\\", 0, "http:foo%2Fbar%2Fba#z\\"},
129 {"http:\\foo/bar\\baz", 0, "http:/foo/bar/baz"},
130 {"http:\\\\foo/bar\\baz", 0, "http://foo/bar/baz"},
131 {"http:\\\\\\foo/bar\\baz", 0, "http:///foo/bar/baz"},
132 {"http:\\\\\\\\foo/bar\\baz", 0, "http:////foo/bar/baz"},
133 {"http:/fo ?o/b ar\\baz", 0, "http:/fo%20?o/b ar\\baz"},
134 {"http:fo ?o/b ar\\baz", 0, "http:fo%20?o/b ar\\baz"},
135 {"http:/foo/bar\\baz", URL_ESCAPE_SEGMENT_ONLY
, "http:%2Ffoo%2Fbar%5Cbaz"},
137 {"https://foo/bar\\baz", 0, "https://foo/bar/baz"},
138 {"https:/foo/bar\\baz", 0, "https:/foo/bar/baz"},
139 {"https:\\foo/bar\\baz", 0, "https:/foo/bar/baz"},
141 {"foo:////foo/bar\\baz", 0, "foo:////foo/bar%5Cbaz"},
142 {"foo:///foo/bar\\baz", 0, "foo:///foo/bar%5Cbaz"},
143 {"foo://localhost/foo/bar\\baz", 0, "foo://localhost/foo/bar%5Cbaz"},
144 {"foo://foo/bar\\baz", 0, "foo://foo/bar%5Cbaz"},
145 {"foo:/foo/bar\\baz", 0, "foo:/foo/bar%5Cbaz"},
146 {"foo:foo/bar\\baz", 0, "foo:foo%2Fbar%5Cbaz"},
147 {"foo:\\foo/bar\\baz", 0, "foo:%5Cfoo%2Fbar%5Cbaz"},
148 {"foo:/foo/bar\\ba?\\z", 0, "foo:/foo/bar%5Cba?\\z"},
149 {"foo:/foo/bar\\ba#\\z", 0, "foo:/foo/bar%5Cba#\\z"},
151 {"mailto:/fo/o@b\\%a?\\r.b#\\az", 0, "mailto:%2Ffo%2Fo@b%5C%a%3F%5Cr.b%23%5Caz"},
152 {"mailto:fo/o@b\\%a?\\r.b#\\az", 0, "mailto:fo%2Fo@b%5C%a%3F%5Cr.b%23%5Caz"},
153 {"mailto:fo/o@b\\%a?\\r.b#\\az", URL_ESCAPE_PERCENT
, "mailto:fo%2Fo@b%5C%25a%3F%5Cr.b%23%5Caz"},
155 {"ftp:fo/o@bar.baz/foo/bar", 0, "ftp:fo%2Fo@bar.baz%2Ffoo%2Fbar"},
156 {"ftp:/fo/o@bar.baz/foo/bar", 0, "ftp:/fo/o@bar.baz/foo/bar"},
157 {"ftp://fo/o@bar.baz/fo?o\\bar", 0, "ftp://fo/o@bar.baz/fo?o\\bar"},
158 {"ftp://fo/o@bar.baz/fo#o\\bar", 0, "ftp://fo/o@bar.baz/fo#o\\bar"},
159 {"ftp://localhost/o@bar.baz/fo#o\\bar", 0, "ftp://localhost/o@bar.baz/fo#o\\bar"},
160 {"ftp:///fo/o@bar.baz/foo/bar", 0, "ftp:///fo/o@bar.baz/foo/bar"},
161 {"ftp:////fo/o@bar.baz/foo/bar", 0, "ftp:////fo/o@bar.baz/foo/bar"},
163 {"ftp\x1f\1end/", 0, "ftp%1F%01end/"}
166 typedef struct _TEST_URL_ESCAPEW
{
167 const WCHAR url
[INTERNET_MAX_URL_LENGTH
];
169 const WCHAR expecturl
[INTERNET_MAX_URL_LENGTH
];
170 const WCHAR win7url
[INTERNET_MAX_URL_LENGTH
]; /* <= Win7 */
173 static const TEST_URL_ESCAPEW TEST_ESCAPEW
[] = {
174 {L
" <>\"", URL_ESCAPE_AS_UTF8
, L
"%20%3C%3E%22"},
175 {L
"{}|\\", URL_ESCAPE_AS_UTF8
, L
"%7B%7D%7C%5C"},
176 {L
"^][`", URL_ESCAPE_AS_UTF8
, L
"%5E%5D%5B%60"},
177 {L
"&/?#", URL_ESCAPE_AS_UTF8
, L
"%26/?#"},
178 {L
"Mass", URL_ESCAPE_AS_UTF8
, L
"Mass"},
180 /* broken < Win8/10 */
181 {L
"Ma\xdf", URL_ESCAPE_AS_UTF8
, L
"Ma%C3%9F", L
"Ma%DF"},
182 {L
"\xd841\xdf0e", URL_ESCAPE_AS_UTF8
, L
"%F0%A0%9C%8E", L
"%EF%BF%BD%EF%BF%BD"}, /* 0x2070E */
183 {L
"\xd85e\xde3e", URL_ESCAPE_AS_UTF8
, L
"%F0%A7%A8%BE", L
"%EF%BF%BD%EF%BF%BD"}, /* 0x27A3E */
184 {L
"\xd85e", URL_ESCAPE_AS_UTF8
, L
"%EF%BF%BD", L
"\xd85e"},
185 {L
"\xd85eQ", URL_ESCAPE_AS_UTF8
, L
"%EF%BF%BDQ", L
"\xd85eQ"},
186 {L
"\xdc00", URL_ESCAPE_AS_UTF8
, L
"%EF%BF%BD", L
"\xdc00"},
187 {L
"\xffff", URL_ESCAPE_AS_UTF8
, L
"%EF%BF%BF", L
"\xffff"},
190 /* ################ */
192 typedef struct _TEST_URL_COMBINE
{
196 const char *expecturl
;
199 static const TEST_URL_COMBINE TEST_COMBINE
[] = {
200 {"http://www.winehq.org/tests", "tests1", 0, "http://www.winehq.org/tests1"},
201 {"http://www.%77inehq.org/tests", "tests1", 0, "http://www.%77inehq.org/tests1"},
202 /*FIXME {"http://www.winehq.org/tests", "../tests2", 0, "http://www.winehq.org/tests2"},*/
203 {"http://www.winehq.org/tests/", "../tests3", 0, "http://www.winehq.org/tests3"},
204 {"http://www.winehq.org/tests/test1", "test2", 0, "http://www.winehq.org/tests/test2"},
205 {"http://www.winehq.org/tests/../tests", "tests4", 0, "http://www.winehq.org/tests4"},
206 {"http://www.winehq.org/tests/../tests/", "tests5", 0, "http://www.winehq.org/tests/tests5"},
207 {"http://www.winehq.org/tests/../tests/", "/tests6/..", 0, "http://www.winehq.org/"},
208 {"http://www.winehq.org/tests/../tests/..", "tests7/..", 0, "http://www.winehq.org/"},
209 {"http://www.winehq.org/tests/?query=x&return=y", "tests8", 0, "http://www.winehq.org/tests/tests8"},
210 {"http://www.winehq.org/tests/#example", "tests9", 0, "http://www.winehq.org/tests/tests9"},
211 {"http://www.winehq.org/tests/../tests/", "/tests10/..", URL_DONT_SIMPLIFY
, "http://www.winehq.org/tests10/.."},
212 {"http://www.winehq.org/tests/../", "tests11", URL_DONT_SIMPLIFY
, "http://www.winehq.org/tests/../tests11"},
213 {"http://www.winehq.org/test12", "#", 0, "http://www.winehq.org/test12#"},
214 {"http://www.winehq.org/test13#aaa", "#bbb", 0, "http://www.winehq.org/test13#bbb"},
215 {"http://www.winehq.org/test14#aaa/bbb#ccc", "#", 0, "http://www.winehq.org/test14#"},
216 {"http://www.winehq.org/tests/?query=x/y/z", "tests15", 0, "http://www.winehq.org/tests/tests15"},
217 {"http://www.winehq.org/tests/?query=x/y/z#example", "tests16", 0, "http://www.winehq.org/tests/tests16"},
218 {"file:///C:\\dir\\file.txt", "test.txt", 0, "file:///C:/dir/test.txt"},
219 {"file:///C:\\dir\\file.txt#hash\\hash", "test.txt", 0, "file:///C:/dir/file.txt#hash/test.txt"},
220 {"file:///C:\\dir\\file.html#hash\\hash", "test.html", 0, "file:///C:/dir/test.html"},
221 {"file:///C:\\dir\\file.htm#hash\\hash", "test.htm", 0, "file:///C:/dir/test.htm"},
222 {"file:///C:\\dir\\file.hTmL#hash\\hash", "test.hTmL", 0, "file:///C:/dir/test.hTmL"},
223 {"file:///C:\\dir.html\\file.txt#hash\\hash", "test.txt", 0, "file:///C:/dir.html/file.txt#hash/test.txt"},
224 {"C:\\winehq\\winehq.txt", "C:\\Test\\test.txt", 0, "file:///C:/Test/test.txt"},
225 {"http://www.winehq.org/test/", "test%20file.txt", 0, "http://www.winehq.org/test/test%20file.txt"},
226 {"http://www.winehq.org/test/", "test%20file.txt", URL_FILE_USE_PATHURL
, "http://www.winehq.org/test/test%20file.txt"},
227 {"http://www.winehq.org%2ftest/", "test%20file.txt", URL_FILE_USE_PATHURL
, "http://www.winehq.org%2ftest/test%20file.txt"},
228 {"xxx:@MSITStore:file.chm/file.html", "dir/file", 0, "xxx:dir/file"},
229 {"mk:@MSITStore:file.chm::/file.html", "/dir/file", 0, "mk:@MSITStore:file.chm::/dir/file"},
230 {"mk:@MSITStore:file.chm::/file.html", "mk:@MSITStore:file.chm::/dir/file", 0, "mk:@MSITStore:file.chm::/dir/file"},
231 {"foo:today", "foo:calendar", 0, "foo:calendar"},
232 {"foo:today", "bar:calendar", 0, "bar:calendar"},
233 {"foo:/today", "foo:calendar", 0, "foo:/calendar"},
234 {"Foo:/today/", "fOo:calendar", 0, "foo:/today/calendar"},
235 {"mk:@MSITStore:dir/test.chm::dir/index.html", "image.jpg", 0, "mk:@MSITStore:dir/test.chm::dir/image.jpg"},
236 {"mk:@MSITStore:dir/test.chm::dir/dir2/index.html", "../image.jpg", 0, "mk:@MSITStore:dir/test.chm::dir/image.jpg"},
237 /* UrlCombine case 2 tests. Schemes do not match */
238 {"outbind://xxxxxxxxx", "http://wine1/dir", 0, "http://wine1/dir"},
239 {"xxxx://xxxxxxxxx", "http://wine2/dir", 0, "http://wine2/dir"},
240 {"ftp://xxxxxxxxx/", "http://wine3/dir", 0, "http://wine3/dir"},
241 {"outbind://xxxxxxxxx", "http://wine4/dir", URL_PLUGGABLE_PROTOCOL
, "http://wine4/dir"},
242 {"xxx://xxxxxxxxx", "http://wine5/dir", URL_PLUGGABLE_PROTOCOL
, "http://wine5/dir"},
243 {"ftp://xxxxxxxxx/", "http://wine6/dir", URL_PLUGGABLE_PROTOCOL
, "http://wine6/dir"},
244 {"http://xxxxxxxxx", "outbind://wine7/dir", 0, "outbind://wine7/dir"},
245 {"xxx://xxxxxxxxx", "ftp://wine8/dir", 0, "ftp://wine8/dir"},
246 {"ftp://xxxxxxxxx/", "xxx://wine9/dir", 0, "xxx://wine9/dir"},
247 {"http://xxxxxxxxx", "outbind://wine10/dir", URL_PLUGGABLE_PROTOCOL
, "outbind://wine10/dir"},
248 {"xxx://xxxxxxxxx", "ftp://wine11/dir", URL_PLUGGABLE_PROTOCOL
, "ftp://wine11/dir"},
249 {"ftp://xxxxxxxxx/", "xxx://wine12/dir", URL_PLUGGABLE_PROTOCOL
, "xxx://wine12/dir"},
250 {"http://xxxxxxxxx", "outbind:wine13/dir", 0, "outbind:wine13/dir"},
251 {"xxx://xxxxxxxxx", "ftp:wine14/dir", 0, "ftp:wine14/dir"},
252 {"ftp://xxxxxxxxx/", "xxx:wine15/dir", 0, "xxx:wine15/dir"},
253 {"outbind://xxxxxxxxx/", "http:wine16/dir", 0, "http:wine16/dir"},
254 {"http://xxxxxxxxx", "outbind:wine17/dir", URL_PLUGGABLE_PROTOCOL
, "outbind:wine17/dir"},
255 {"xxx://xxxxxxxxx", "ftp:wine18/dir", URL_PLUGGABLE_PROTOCOL
, "ftp:wine18/dir"},
256 {"ftp://xxxxxxxxx/", "xXx:wine19/dir", URL_PLUGGABLE_PROTOCOL
, "xxx:wine19/dir"},
257 {"outbind://xxxxxxxxx/", "http:wine20/dir", URL_PLUGGABLE_PROTOCOL
, "http:wine20/dir"},
258 {"file:///c:/dir/file.txt", "index.html?test=c:/abc", URL_ESCAPE_SPACES_ONLY
|URL_DONT_ESCAPE_EXTRA_INFO
, "file:///c:/dir/index.html?test=c:/abc"}
261 /* ################ */
263 static const struct {
267 } TEST_URLFROMPATH
[] = {
268 {"foo", "file:foo", S_OK
},
269 {"foo\\bar", "file:foo/bar", S_OK
},
270 {"\\foo\\bar", "file:///foo/bar", S_OK
},
271 {"c:\\foo\\bar", "file:///c:/foo/bar", S_OK
},
272 {"c:foo\\bar", "file:///c:foo/bar", S_OK
},
273 {"c:\\foo/b a%r", "file:///c:/foo/b%20a%25r", S_OK
},
274 {"c:\\foo\\foo bar", "file:///c:/foo/foo%20bar", S_OK
},
275 {"file:///c:/foo/bar", "file:///c:/foo/bar", S_FALSE
},
276 {"xx:c:\\foo\\bar", "xx:c:\\foo\\bar", S_FALSE
}
279 /* ################ */
284 } TEST_URL_UNESCAPE
[] = {
285 {"file://foo/bar", "file://foo/bar"},
286 {"file://fo%20o%5Ca/bar", "file://fo o\\a/bar"},
287 {"file://%24%25foobar", "file://$%foobar"}
295 } TEST_URL_UNESCAPEW
[] =
297 { L
"file://foo/bar", L
"file://foo/bar" },
298 { L
"file://fo%20o%5Ca/bar", L
"file://fo o\\a/bar" },
299 { L
"file://%24%25foobar", L
"file://$%foobar" },
300 { L
"file:///C:/Program Files", L
"file:///C:/Program Files" },
301 { L
"file:///C:/Program Files", L
"file:///C:/Program Files", URL_UNESCAPE_AS_UTF8
},
302 { L
"file:///C:/Program%20Files", L
"file:///C:/Program Files" },
303 { L
"file:///C:/Program%20Files", L
"file:///C:/Program Files", URL_UNESCAPE_AS_UTF8
},
304 { L
"file://foo/%E4%B8%AD%E6%96%87/bar", L
"file://foo/\xe4\xb8\xad\xe6\x96\x87/bar" }, /* with 3 btyes utf-8 */
305 { L
"file://foo/%E4%B8%AD%E6%96%87/bar", L
"file://foo/\x4e2d\x6587/bar", URL_UNESCAPE_AS_UTF8
},
306 /* mix corrupt and good utf-8 */
307 { L
"file://foo/%E4%AD%E6%96%87/bar", L
"file://foo/\xfffd\x6587/bar", URL_UNESCAPE_AS_UTF8
},
308 { L
"file://foo/%F0%9F%8D%B7/bar", L
"file://foo/\xf0\x9f\x8d\xb7/bar" }, /* with 4 btyes utf-8 */
309 { L
"file://foo/%F0%9F%8D%B7/bar", L
"file://foo/\xd83c\xdf77/bar", URL_UNESCAPE_AS_UTF8
},
310 /* non-escaped chars between multi-byte escaped chars */
311 { L
"file://foo/%E4%B8%ADabc%E6%96%87/bar", L
"file://foo/\x4e2d""abc""\x6587/bar", URL_UNESCAPE_AS_UTF8
},
312 { L
"file://foo/%E4B8%AD/bar", L
"file://foo/\xfffd""B8\xfffd/bar", URL_UNESCAPE_AS_UTF8
},
313 { L
"file://foo/%E4%G8%AD/bar", L
"file://foo/\xfffd""%G8\xfffd/bar", URL_UNESCAPE_AS_UTF8
},
314 { L
"file://foo/%G4%B8%AD/bar", L
"file://foo/%G4\xfffd\xfffd/bar", URL_UNESCAPE_AS_UTF8
},
317 static const struct {
320 } TEST_PATH_IS_URL
[] = {
321 {"http://foo/bar", TRUE
},
322 {"c:\\foo\\bar", FALSE
},
323 {"foo://foo/bar", TRUE
},
326 {"bogusscheme:", TRUE
},
327 {"http:partial", TRUE
}
330 /* ################ */
332 static const struct {
336 } TEST_URLIS_ATTRIBS
[] = {
337 { "ftp:", FALSE
, FALSE
},
338 { "http:", FALSE
, FALSE
},
339 { "gopher:", FALSE
, FALSE
},
340 { "mailto:", TRUE
, FALSE
},
341 { "news:", FALSE
, FALSE
},
342 { "nntp:", FALSE
, FALSE
},
343 { "telnet:", FALSE
, FALSE
},
344 { "wais:", FALSE
, FALSE
},
345 { "file:", FALSE
, TRUE
},
346 { "mk:", FALSE
, FALSE
},
347 { "https:", FALSE
, FALSE
},
348 { "shell:", TRUE
, FALSE
},
349 { "https:", FALSE
, FALSE
},
350 { "snews:", FALSE
, FALSE
},
351 { "local:", FALSE
, FALSE
},
352 { "javascript:", TRUE
, FALSE
},
353 { "vbscript:", TRUE
, FALSE
},
354 { "about:", TRUE
, FALSE
},
355 { "res:", FALSE
, FALSE
},
356 { "bogusscheme:", FALSE
, FALSE
},
357 { "file:\\\\e:\\b\\c", FALSE
, TRUE
},
358 { "file://e:/b/c", FALSE
, TRUE
},
359 { "http:partial", FALSE
, FALSE
},
360 { "mailto://www.winehq.org/test.html", TRUE
, FALSE
},
361 { "file:partial", FALSE
, TRUE
},
362 { "File:partial", FALSE
, TRUE
},
365 /* ########################### */
367 static LPWSTR
GetWideString(const char* szString
)
369 LPWSTR wszString
= HeapAlloc(GetProcessHeap(), 0, (2*INTERNET_MAX_URL_LENGTH
) * sizeof(WCHAR
));
371 MultiByteToWideChar(CP_ACP
, 0, szString
, -1, wszString
, INTERNET_MAX_URL_LENGTH
);
377 static void FreeWideString(LPWSTR wszString
)
379 HeapFree(GetProcessHeap(), 0, wszString
);
382 /* ########################### */
384 static void test_UrlApplyScheme(void)
386 WCHAR urlW
[INTERNET_MAX_URL_LENGTH
], newurlW
[INTERNET_MAX_URL_LENGTH
], expectW
[INTERNET_MAX_URL_LENGTH
];
387 char newurl
[INTERNET_MAX_URL_LENGTH
];
392 for (i
= 0; i
< ARRAY_SIZE(TEST_APPLY
); i
++) {
393 len
= ARRAY_SIZE(newurl
);
394 strcpy(newurl
, "untouched");
395 res
= UrlApplySchemeA(TEST_APPLY
[i
].url
, newurl
, &len
, TEST_APPLY
[i
].flags
);
396 ok( res
== TEST_APPLY
[i
].res
,
397 "#%ldA: got HRESULT 0x%lx (expected 0x%lx)\n", i
, res
, TEST_APPLY
[i
].res
);
400 ok(len
== strlen(newurl
), "Test %lu: Expected length %Iu, got %lu.\n", i
, strlen(newurl
), len
);
401 ok(!strcmp(newurl
, TEST_APPLY
[i
].newurl
), "Test %lu: Expected %s, got %s.\n",
402 i
, debugstr_a(TEST_APPLY
[i
].newurl
), debugstr_a(newurl
));
406 ok(len
== ARRAY_SIZE(newurl
), "Test %lu: Got length %lu.\n", i
, len
);
407 ok(!strcmp(newurl
, "untouched"), "Test %lu: Got %s.\n", i
, debugstr_a(newurl
));
410 /* returned length is in character */
411 MultiByteToWideChar(CP_ACP
, 0, TEST_APPLY
[i
].url
, -1, urlW
, ARRAY_SIZE(urlW
));
412 MultiByteToWideChar(CP_ACP
, 0, TEST_APPLY
[i
].newurl
, -1, expectW
, ARRAY_SIZE(expectW
));
414 len
= ARRAY_SIZE(newurlW
);
415 wcscpy(newurlW
, L
"untouched");
416 res
= UrlApplySchemeW(urlW
, newurlW
, &len
, TEST_APPLY
[i
].flags
);
417 ok( res
== TEST_APPLY
[i
].res
,
418 "#%ldW: got HRESULT 0x%lx (expected 0x%lx)\n", i
, res
, TEST_APPLY
[i
].res
);
421 ok(len
== wcslen(newurlW
), "Test %lu: Expected length %Iu, got %lu.\n", i
, wcslen(newurlW
), len
);
422 ok(!wcscmp(newurlW
, expectW
), "Test %lu: Expected %s, got %s.\n",
423 i
, debugstr_w(expectW
), debugstr_w(newurlW
));
427 ok(len
== ARRAY_SIZE(newurlW
), "Test %lu: Got length %lu.\n", i
, len
);
428 ok(!wcscmp(newurlW
, L
"untouched"), "Test %lu: Got %s.\n", i
, debugstr_w(newurlW
));
432 /* buffer too small */
433 lstrcpyA(newurl
, untouchedA
);
434 len
= lstrlenA(TEST_APPLY
[0].newurl
);
435 res
= UrlApplySchemeA(TEST_APPLY
[0].url
, newurl
, &len
, TEST_APPLY
[0].flags
);
436 ok(res
== E_POINTER
, "got HRESULT 0x%lx (expected E_POINTER)\n", res
);
437 /* The returned length include the space for the terminating 0 */
438 i
= lstrlenA(TEST_APPLY
[0].newurl
)+1;
439 ok(len
== i
, "got len %ld (expected %ld)\n", len
, i
);
440 ok(!lstrcmpA(newurl
, untouchedA
), "got '%s' (expected '%s')\n", newurl
, untouchedA
);
442 /* NULL as parameter. The length and the buffer are not modified */
443 lstrcpyA(newurl
, untouchedA
);
444 len
= ARRAY_SIZE(newurl
);
445 res
= UrlApplySchemeA(NULL
, newurl
, &len
, TEST_APPLY
[0].flags
);
446 ok(res
== E_INVALIDARG
, "got HRESULT 0x%lx (expected E_INVALIDARG)\n", res
);
447 ok(len
== ARRAY_SIZE(newurl
), "got len %ld\n", len
);
448 ok(!lstrcmpA(newurl
, untouchedA
), "got '%s' (expected '%s')\n", newurl
, untouchedA
);
450 len
= ARRAY_SIZE(newurl
);
451 res
= UrlApplySchemeA(TEST_APPLY
[0].url
, NULL
, &len
, TEST_APPLY
[0].flags
);
452 ok(res
== E_INVALIDARG
, "got HRESULT 0x%lx (expected E_INVALIDARG)\n", res
);
453 ok(len
== ARRAY_SIZE(newurl
), "got len %ld\n", len
);
455 lstrcpyA(newurl
, untouchedA
);
456 res
= UrlApplySchemeA(TEST_APPLY
[0].url
, newurl
, NULL
, TEST_APPLY
[0].flags
);
457 ok(res
== E_INVALIDARG
, "got HRESULT 0x%lx (expected E_INVALIDARG)\n", res
);
458 ok(!lstrcmpA(newurl
, untouchedA
), "got '%s' (expected '%s')\n", newurl
, untouchedA
);
462 /* ########################### */
464 static void hash_url(const char* szUrl
)
466 LPCSTR szTestUrl
= szUrl
;
467 LPWSTR wszTestUrl
= GetWideString(szTestUrl
);
470 DWORD cbSize
= sizeof(DWORD
);
471 DWORD dwHash1
, dwHash2
;
472 res
= UrlHashA(szTestUrl
, (LPBYTE
)&dwHash1
, cbSize
);
473 ok(res
== S_OK
, "UrlHashA returned 0x%lx (expected S_OK) for %s\n", res
, szUrl
);
475 res
= UrlHashW(wszTestUrl
, (LPBYTE
)&dwHash2
, cbSize
);
476 ok(res
== S_OK
, "UrlHashW returned 0x%lx (expected S_OK) for %s\n", res
, szUrl
);
477 ok(dwHash1
== dwHash2
,
478 "Hashes didn't match (A: 0x%lx, W: 0x%lx) for %s\n", dwHash1
, dwHash2
, szUrl
);
479 FreeWideString(wszTestUrl
);
482 static void test_UrlHash(void)
484 hash_url(TEST_URL_1
);
485 hash_url(TEST_URL_2
);
486 hash_url(TEST_URL_3
);
489 static void test_UrlGetPart(void)
507 {"hi", URL_PART_SCHEME
, 0, S_FALSE
, ""},
508 {"hi", URL_PART_USERNAME
, 0, E_FAIL
},
509 {"hi", URL_PART_PASSWORD
, 0, E_FAIL
},
510 {"hi", URL_PART_HOSTNAME
, 0, E_FAIL
},
511 {"hi", URL_PART_PORT
, 0, E_FAIL
},
512 {"hi", URL_PART_QUERY
, 0, S_FALSE
, ""},
514 {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_SCHEME
, 0, S_OK
, "http"},
515 {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_USERNAME
, 0, S_OK
, "foo"},
516 {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_PASSWORD
, 0, S_OK
, "bar"},
517 {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_HOSTNAME
, 0, S_OK
, "localhost"},
518 {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_PORT
, 0, S_OK
, "21"},
519 {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_QUERY
, 0, S_OK
, "query=x&return=y"},
520 {"http://foo:bar@localhost:21/internal.php#anchor", URL_PART_QUERY
, 0, S_FALSE
, ""},
521 {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_SCHEME
, URL_PARTFLAG_KEEPSCHEME
, S_OK
, "http"},
522 {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_USERNAME
, URL_PARTFLAG_KEEPSCHEME
, S_OK
, "http:foo"},
523 {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_PASSWORD
, URL_PARTFLAG_KEEPSCHEME
, S_OK
, "http:bar"},
524 {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_HOSTNAME
, URL_PARTFLAG_KEEPSCHEME
, S_OK
, "http:localhost"},
525 {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_PORT
, URL_PARTFLAG_KEEPSCHEME
, S_OK
, "http:21"},
526 {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_QUERY
, URL_PARTFLAG_KEEPSCHEME
, S_OK
, "query=x&return=y"},
528 {"http://localhost/", URL_PART_USERNAME
, 0, E_INVALIDARG
},
529 {"http://localhost/", URL_PART_PASSWORD
, 0, E_INVALIDARG
},
530 {"http://localhost/", URL_PART_HOSTNAME
, 0, S_OK
, "localhost"},
531 {"http://localhost/", URL_PART_PORT
, 0, E_INVALIDARG
},
532 {"http://localhost/", URL_PART_QUERY
, 0, S_FALSE
, ""},
534 {"http://localhost:port/", URL_PART_USERNAME
, 0, E_INVALIDARG
},
535 {"http://localhost:port/", URL_PART_PASSWORD
, 0, E_INVALIDARG
},
536 {"http://localhost:port/", URL_PART_HOSTNAME
, 0, S_OK
, "localhost"},
537 {"http://localhost:port/", URL_PART_PORT
, 0, S_OK
, "port"},
538 {"http://:", URL_PART_HOSTNAME
, 0, S_FALSE
, ""},
539 {"http://:", URL_PART_PORT
, 0, S_FALSE
, ""},
541 {"http://user@localhost", URL_PART_USERNAME
, 0, S_OK
, "user"},
542 {"http://user@localhost", URL_PART_PASSWORD
, 0, E_INVALIDARG
},
543 {"http://user@localhost", URL_PART_HOSTNAME
, 0, S_OK
, "localhost"},
544 {"http://user@localhost", URL_PART_PORT
, 0, E_INVALIDARG
},
545 {"http://@", URL_PART_USERNAME
, 0, S_FALSE
, ""},
546 {"http://@", URL_PART_PASSWORD
, 0, E_INVALIDARG
},
547 {"http://@", URL_PART_HOSTNAME
, 0, S_FALSE
, ""},
549 {"http://user:pass@localhost", URL_PART_USERNAME
, 0, S_OK
, "user"},
550 {"http://user:pass@localhost", URL_PART_PASSWORD
, 0, S_OK
, "pass"},
551 {"http://user:pass@localhost", URL_PART_HOSTNAME
, 0, S_OK
, "localhost"},
552 {"http://user:pass@localhost", URL_PART_PORT
, 0, E_INVALIDARG
},
553 {"http://:@", URL_PART_USERNAME
, 0, S_FALSE
, ""},
554 {"http://:@", URL_PART_PASSWORD
, 0, S_FALSE
, ""},
555 {"http://:@", URL_PART_HOSTNAME
, 0, S_FALSE
, ""},
557 {"http://host:port:q", URL_PART_HOSTNAME
, 0, S_OK
, "host"},
558 {"http://host:port:q", URL_PART_PORT
, 0, S_OK
, "port:q"},
559 {"http://user:pass:q@host", URL_PART_USERNAME
, 0, S_OK
, "user"},
560 {"http://user:pass:q@host", URL_PART_PASSWORD
, 0, S_OK
, "pass:q"},
561 {"http://user@host@q", URL_PART_USERNAME
, 0, S_OK
, "user"},
562 {"http://user@host@q", URL_PART_HOSTNAME
, 0, S_OK
, "host@q"},
564 {"http:localhost/index.html", URL_PART_HOSTNAME
, 0, E_FAIL
},
565 {"http:/localhost/index.html", URL_PART_HOSTNAME
, 0, E_FAIL
},
567 {"http://localhost\\index.html", URL_PART_HOSTNAME
, 0, S_OK
, "localhost"},
568 {"http:/\\localhost/index.html", URL_PART_HOSTNAME
, 0, S_OK
, "localhost"},
569 {"http:\\/localhost/index.html", URL_PART_HOSTNAME
, 0, S_OK
, "localhost"},
571 {"ftp://localhost\\index.html", URL_PART_HOSTNAME
, 0, S_OK
, "localhost"},
572 {"ftp:/\\localhost/index.html", URL_PART_HOSTNAME
, 0, S_OK
, "localhost"},
573 {"ftp:\\/localhost/index.html", URL_PART_HOSTNAME
, 0, S_OK
, "localhost"},
575 {"http://host?a:b@c:d", URL_PART_HOSTNAME
, 0, S_OK
, "host"},
576 {"http://host?a:b@c:d", URL_PART_QUERY
, 0, S_OK
, "a:b@c:d"},
577 {"http://host#a:b@c:d", URL_PART_HOSTNAME
, 0, S_OK
, "host"},
578 {"http://host#a:b@c:d", URL_PART_QUERY
, 0, S_FALSE
, ""},
580 /* All characters, other than those with special meaning, are allowed. */
581 {"http://foo:bar@google.*.com:21/internal.php?query=x&return=y", URL_PART_HOSTNAME
, 0, S_OK
, "google.*.com"},
582 {"http:// !\"$%&'()*+,-.;<=>[]^_`{|~}:pass@host", URL_PART_USERNAME
, 0, S_OK
, " !\"$%&'()*+,-.;<=>[]^_`{|~}"},
583 {"http://user: !\"$%&'()*+,-.;<=>[]^_`{|~}@host", URL_PART_PASSWORD
, 0, S_OK
, " !\"$%&'()*+,-.;<=>[]^_`{|~}"},
584 {"http:// !\"$%&'()*+,-.;<=>[]^_`{|~}", URL_PART_HOSTNAME
, 0, S_OK
, " !\"$%&'()*+,-.;<=>[]^_`{|~}"},
585 {"http://host: !\"$%&'()*+,-.;<=>[]^_`{|~}", URL_PART_PORT
, 0, S_OK
, " !\"$%&'()*+,-.;<=>[]^_`{|~}"},
587 {"http:///index.html", URL_PART_HOSTNAME
, 0, S_FALSE
, ""},
588 {"http:///index.html", URL_PART_HOSTNAME
, URL_PARTFLAG_KEEPSCHEME
, S_OK
, "http:"},
589 {"file://h o s t/c:/windows/file", URL_PART_HOSTNAME
, 0, S_OK
, "h o s t"},
590 {"file://h o s t/c:/windows/file", URL_PART_HOSTNAME
, URL_PARTFLAG_KEEPSCHEME
, S_OK
, "h o s t"},
591 {"file://foo:bar@localhost:21/file?query=x", URL_PART_USERNAME
, 0, E_FAIL
},
592 {"file://foo:bar@localhost:21/file?query=x", URL_PART_PASSWORD
, 0, E_FAIL
},
593 {"file://foo:bar@localhost:21/file?query=x", URL_PART_HOSTNAME
, 0, S_OK
, "foo:bar@localhost:21"},
594 {"file://foo:bar@localhost:21/file?query=x", URL_PART_PORT
, 0, E_FAIL
},
595 {"file://foo:bar@localhost:21/file?query=x", URL_PART_QUERY
, 0, S_OK
, "query=x"},
596 {"http://user:pass 123@www.wine hq.org", URL_PART_HOSTNAME
, 0, S_OK
, "www.wine hq.org"},
597 {"http://user:pass 123@www.wine hq.org", URL_PART_PASSWORD
, 0, S_OK
, "pass 123"},
598 {"about:blank", URL_PART_SCHEME
, 0, S_OK
, "about"},
599 {"about:blank", URL_PART_HOSTNAME
, 0, E_FAIL
},
600 {"x-excid://36C00000/guid:{048B4E89-2E92-496F-A837-33BA02FF6D32}/Message.htm", URL_PART_SCHEME
, 0, S_OK
, "x-excid"},
601 {"x-excid://36C00000/guid:{048B4E89-2E92-496F-A837-33BA02FF6D32}/Message.htm", URL_PART_HOSTNAME
, 0, E_FAIL
},
602 {"x-excid://36C00000/guid:{048B4E89-2E92-496F-A837-33BA02FF6D32}/Message.htm", URL_PART_QUERY
, 0, S_FALSE
, ""},
603 {"foo://bar-url/test", URL_PART_SCHEME
, 0, S_OK
, "foo"},
604 {"foo://bar-url/test", URL_PART_HOSTNAME
, 0, E_FAIL
},
605 {"foo://bar-url/test", URL_PART_QUERY
, 0, S_FALSE
, ""},
606 {"ascheme:", URL_PART_SCHEME
, 0, S_OK
, "ascheme"},
607 {"res://some.dll/find.dlg", URL_PART_SCHEME
, 0, S_OK
, "res"},
608 {"res://some.dll/find.dlg", URL_PART_QUERY
, 0, S_FALSE
, ""},
609 {"http://www.winehq.org", URL_PART_HOSTNAME
, URL_PARTFLAG_KEEPSCHEME
, S_OK
, "http:www.winehq.org"},
610 {"file:///index.html", URL_PART_HOSTNAME
, 0, S_FALSE
, ""},
611 {"file:///index.html", URL_PART_HOSTNAME
, URL_PARTFLAG_KEEPSCHEME
, S_FALSE
, ""},
612 {"file://c:\\index.htm", URL_PART_HOSTNAME
, 0, S_FALSE
, ""},
613 {"file://c:\\index.htm", URL_PART_HOSTNAME
, URL_PARTFLAG_KEEPSCHEME
, S_FALSE
, ""},
614 {"file:some text", URL_PART_HOSTNAME
, 0, S_FALSE
, ""},
615 {"index.htm", URL_PART_HOSTNAME
, 0, E_FAIL
},
616 {"sChEmE-.+:", URL_PART_SCHEME
, 0, S_OK
, "scheme-.+"},
617 {"scheme_:", URL_PART_SCHEME
, 0, S_FALSE
, ""},
618 {"scheme :", URL_PART_SCHEME
, 0, S_FALSE
, ""},
619 {"sch eme:", URL_PART_SCHEME
, 0, S_FALSE
, ""},
620 {":", URL_PART_SCHEME
, 0, S_FALSE
, ""},
621 {"a:", URL_PART_SCHEME
, 0, S_FALSE
, ""},
622 {"0:", URL_PART_SCHEME
, 0, S_FALSE
, ""},
623 {"ab:", URL_PART_SCHEME
, 0, S_OK
, "ab"},
625 {"about://hostname/", URL_PART_HOSTNAME
, 0, E_FAIL
},
626 {"file://hostname/", URL_PART_HOSTNAME
, 0, S_OK
, "hostname"},
627 {"ftp://hostname/", URL_PART_HOSTNAME
, 0, S_OK
, "hostname"},
628 {"gopher://hostname/", URL_PART_HOSTNAME
, 0, S_OK
, "hostname"},
629 {"http://hostname/", URL_PART_HOSTNAME
, 0, S_OK
, "hostname"},
630 {"https://hostname/", URL_PART_HOSTNAME
, 0, S_OK
, "hostname"},
631 {"javascript://hostname/", URL_PART_HOSTNAME
, 0, E_FAIL
},
632 {"local://hostname/", URL_PART_HOSTNAME
, 0, E_FAIL
},
633 {"mailto://hostname/", URL_PART_HOSTNAME
, 0, E_FAIL
},
634 {"mk://hostname/", URL_PART_HOSTNAME
, 0, E_FAIL
},
635 {"news://hostname/", URL_PART_HOSTNAME
, 0, S_OK
, "hostname"},
636 {"nntp://hostname/", URL_PART_HOSTNAME
, 0, S_OK
, "hostname"},
637 {"res://hostname/", URL_PART_HOSTNAME
, 0, E_FAIL
},
638 {"shell://hostname/", URL_PART_HOSTNAME
, 0, E_FAIL
},
639 {"snews://hostname/", URL_PART_HOSTNAME
, 0, S_OK
, "hostname"},
640 {"telnet://hostname/", URL_PART_HOSTNAME
, 0, S_OK
, "hostname"},
641 {"vbscript://hostname/", URL_PART_HOSTNAME
, 0, E_FAIL
},
642 {"wais://hostname/", URL_PART_HOSTNAME
, 0, E_FAIL
},
644 {"file://hostname/", URL_PART_HOSTNAME
, URL_PARTFLAG_KEEPSCHEME
, S_OK
, "hostname"},
645 {"ftp://hostname/", URL_PART_HOSTNAME
, URL_PARTFLAG_KEEPSCHEME
, S_OK
, "ftp:hostname"},
646 {"gopher://hostname/", URL_PART_HOSTNAME
, URL_PARTFLAG_KEEPSCHEME
, S_OK
, "gopher:hostname"},
647 {"http://hostname/", URL_PART_HOSTNAME
, URL_PARTFLAG_KEEPSCHEME
, S_OK
, "http:hostname"},
648 {"https://hostname/", URL_PART_HOSTNAME
, URL_PARTFLAG_KEEPSCHEME
, S_OK
, "https:hostname"},
649 {"news://hostname/", URL_PART_HOSTNAME
, URL_PARTFLAG_KEEPSCHEME
, S_OK
, "news:hostname"},
650 {"nntp://hostname/", URL_PART_HOSTNAME
, URL_PARTFLAG_KEEPSCHEME
, S_OK
, "nntp:hostname"},
651 {"snews://hostname/", URL_PART_HOSTNAME
, URL_PARTFLAG_KEEPSCHEME
, S_OK
, "snews:hostname"},
652 {"telnet://hostname/", URL_PART_HOSTNAME
, URL_PARTFLAG_KEEPSCHEME
, S_OK
, "telnet:hostname"},
655 hr
= UrlGetPartA(NULL
, NULL
, NULL
, URL_PART_SCHEME
, 0);
656 ok(hr
== E_INVALIDARG
, "Got hr %#lx.\n", hr
);
658 hr
= UrlGetPartA(NULL
, buffer
, &size
, URL_PART_SCHEME
, 0);
659 ok(hr
== E_INVALIDARG
, "Got hr %#lx.\n", hr
);
661 hr
= UrlGetPartA("res://some.dll/find.dlg", NULL
, &size
, URL_PART_SCHEME
, 0);
662 ok(hr
== E_INVALIDARG
, "Got hr %#lx.\n", hr
);
664 hr
= UrlGetPartA("res://some.dll/find.dlg", buffer
, NULL
, URL_PART_SCHEME
, 0);
665 ok(hr
== E_INVALIDARG
, "Got hr %#lx.\n", hr
);
669 hr
= UrlGetPartA("hi", buffer
, &size
, URL_PART_SCHEME
, 0);
670 ok(hr
== E_INVALIDARG
, "Got hr %#lx.\n", hr
);
671 ok(!strcmp(buffer
, "x"), "Got result %s.\n", debugstr_a(buffer
));
672 ok(!size
, "Got size %lu.\n", size
);
674 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
676 WCHAR urlW
[200], expectW
[200];
677 const char *expect
= tests
[i
].expect
;
678 const char *url
= tests
[i
].url
;
679 DWORD flags
= tests
[i
].flags
;
680 DWORD part
= tests
[i
].part
;
682 winetest_push_context("URL %s, part %#lx, flags %#lx", debugstr_a(url
), part
, flags
);
686 hr
= UrlGetPartA(url
, buffer
, &size
, part
, flags
);
687 if (tests
[i
].hr
== S_OK
)
688 ok(hr
== E_POINTER
, "Got hr %#lx.\n", hr
);
690 ok(hr
== tests
[i
].hr
, "Got hr %#lx.\n", hr
);
694 ok(!size
, "Got size %lu.\n", size
);
695 ok(!buffer
[0], "Got result %s.\n", debugstr_a(buffer
));
700 ok(size
== strlen(expect
) + 1, "Got size %lu.\n", size
);
702 ok(size
== 1, "Got size %lu.\n", size
);
703 ok(!strcmp(buffer
, "x"), "Got result %s.\n", debugstr_a(buffer
));
706 size
= sizeof(buffer
);
708 hr
= UrlGetPartA(url
, buffer
, &size
, part
, flags
);
709 ok(hr
== tests
[i
].hr
, "Got hr %#lx.\n", hr
);
712 ok(size
== strlen(buffer
), "Got size %lu.\n", size
);
713 ok(!strcmp(buffer
, expect
), "Got result %s.\n", debugstr_a(buffer
));
717 ok(size
== sizeof(buffer
), "Got size %lu.\n", size
);
718 ok(!strcmp(buffer
, "x"), "Got result %s.\n", debugstr_a(buffer
));
721 MultiByteToWideChar(CP_ACP
, 0, url
, -1, urlW
, ARRAY_SIZE(urlW
));
724 wcscpy(bufferW
, L
"x");
725 hr
= UrlGetPartW(urlW
, bufferW
, &size
, part
, flags
);
726 if (tests
[i
].hr
== S_OK
)
727 ok(hr
== E_POINTER
, "Got hr %#lx.\n", hr
);
729 ok(hr
== (tests
[i
].hr
== S_FALSE
? S_OK
: tests
[i
].hr
), "Got hr %#lx.\n", hr
);
733 ok(!size
, "Got size %lu.\n", size
);
734 ok(!buffer
[0], "Got result %s.\n", debugstr_a(buffer
));
739 ok(size
== strlen(expect
) + 1, "Got size %lu.\n", size
);
741 ok(size
== 1, "Got size %lu.\n", size
);
742 ok(!wcscmp(bufferW
, L
"x"), "Got result %s.\n", debugstr_w(bufferW
));
745 size
= ARRAY_SIZE(bufferW
);
746 wcscpy(bufferW
, L
"x");
747 hr
= UrlGetPartW(urlW
, bufferW
, &size
, part
, flags
);
748 ok(hr
== (tests
[i
].hr
== S_FALSE
? S_OK
: tests
[i
].hr
), "Got hr %#lx.\n", hr
);
751 ok(size
== wcslen(bufferW
), "Got size %lu.\n", size
);
752 MultiByteToWideChar(CP_ACP
, 0, buffer
, -1, expectW
, ARRAY_SIZE(expectW
));
753 ok(!wcscmp(bufferW
, expectW
), "Got result %s.\n", debugstr_w(bufferW
));
757 ok(size
== ARRAY_SIZE(bufferW
), "Got size %lu.\n", size
);
758 ok(!wcscmp(bufferW
, L
"x"), "Got result %s.\n", debugstr_w(bufferW
));
761 winetest_pop_context();
764 /* Test non-ASCII characters. */
766 size
= ARRAY_SIZE(bufferW
);
767 wcscpy(bufferW
, L
"x");
768 hr
= UrlGetPartW(L
"http://\x01\x7f\x80\xff:pass@host", bufferW
, &size
, URL_PART_USERNAME
, 0);
769 ok(hr
== S_OK
, "Got hr %#lx.\n", hr
);
770 ok(size
== wcslen(bufferW
), "Got size %lu.\n", size
);
771 ok(!wcscmp(bufferW
, L
"\x01\x7f\x80\xff"), "Got result %s.\n", debugstr_w(bufferW
));
774 /* ########################### */
775 static void check_url_canonicalize(const char *url
, DWORD flags
, const char *expect
)
777 char output
[INTERNET_MAX_URL_LENGTH
];
778 WCHAR outputW
[INTERNET_MAX_URL_LENGTH
];
779 WCHAR
*urlW
= GetWideString(url
);
784 winetest_push_context("URL %s, flags %#lx", debugstr_a(url
), flags
);
786 size
= INTERNET_MAX_URL_LENGTH
;
787 hr
= UrlCanonicalizeA(url
, NULL
, &size
, flags
);
788 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#lx.\n", hr
);
789 hr
= UrlCanonicalizeA(url
, output
, &size
, flags
);
790 ok(hr
== S_OK
|| (!url
[0] && hr
== S_FALSE
) /* Vista+ */, "Got unexpected hr %#lx.\n", hr
);
791 ok(!strcmp(output
, expect
), "Expected %s, got %s.\n", debugstr_a(expect
), debugstr_a(output
));
793 size
= INTERNET_MAX_URL_LENGTH
;
794 hr
= UrlCanonicalizeW(urlW
, NULL
, &size
, flags
);
795 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#lx.\n", hr
);
796 hr
= UrlCanonicalizeW(urlW
, outputW
, &size
, flags
);
797 ok(hr
== S_OK
, "Got unexpected hr %#lx.\n", hr
);
799 expectW
= GetWideString(output
);
800 ok(!wcscmp(outputW
, expectW
), "Expected %s, got %s.\n", debugstr_w(expectW
), debugstr_w(outputW
));
801 FreeWideString(expectW
);
803 FreeWideString(urlW
);
805 winetest_pop_context();
809 static void test_UrlEscapeA(void)
814 char empty_string
[] = "";
816 ret
= UrlEscapeA("/woningplan/woonkamer basis.swf", NULL
, &size
, URL_ESCAPE_SPACES_ONLY
);
817 ok(ret
== E_INVALIDARG
, "got %lx, expected %lx\n", ret
, E_INVALIDARG
);
818 ok(size
== 0, "got %ld, expected %d\n", size
, 0);
821 ret
= UrlEscapeA("/woningplan/woonkamer basis.swf", empty_string
, &size
, URL_ESCAPE_SPACES_ONLY
);
822 ok(ret
== E_INVALIDARG
, "got %lx, expected %lx\n", ret
, E_INVALIDARG
);
823 ok(size
== 0, "got %ld, expected %d\n", size
, 0);
826 ret
= UrlEscapeA("/woningplan/woonkamer basis.swf", NULL
, &size
, URL_ESCAPE_SPACES_ONLY
);
827 ok(ret
== E_INVALIDARG
, "got %lx, expected %lx\n", ret
, E_INVALIDARG
);
828 ok(size
== 1, "got %ld, expected %d\n", size
, 1);
831 ret
= UrlEscapeA("/woningplan/woonkamer basis.swf", empty_string
, NULL
, URL_ESCAPE_SPACES_ONLY
);
832 ok(ret
== E_INVALIDARG
, "got %lx, expected %lx\n", ret
, E_INVALIDARG
);
833 ok(size
== 1, "got %ld, expected %d\n", size
, 1);
836 empty_string
[0] = 127;
837 ret
= UrlEscapeA("/woningplan/woonkamer basis.swf", empty_string
, &size
, URL_ESCAPE_SPACES_ONLY
);
838 ok(ret
== E_POINTER
, "got %lx, expected %lx\n", ret
, E_POINTER
);
839 ok(size
== 34, "got %ld, expected %d\n", size
, 34);
840 ok(empty_string
[0] == 127, "String has changed, empty_string[0] = %d\n", empty_string
[0]);
843 empty_string
[0] = 127;
844 ret
= UrlEscapeA("/woningplan/woonkamer basis.swf", empty_string
, &size
, URL_ESCAPE_AS_UTF8
);
845 ok(ret
== E_NOTIMPL
, "Got unexpected hr %#lx.\n", ret
);
846 ok(size
== 1, "Got unexpected size %lu.\n", size
);
847 ok(empty_string
[0] == 127, "String has changed, empty_string[0] = %d\n", empty_string
[0]);
849 for (i
= 0; i
< ARRAY_SIZE(TEST_ESCAPE
); i
++) {
850 CHAR ret_url
[INTERNET_MAX_URL_LENGTH
];
852 size
= INTERNET_MAX_URL_LENGTH
;
853 ret
= UrlEscapeA(TEST_ESCAPE
[i
].url
, ret_url
, &size
, TEST_ESCAPE
[i
].flags
);
854 ok(ret
== S_OK
, "Got unexpected hr %#lx for %s.\n", ret
, debugstr_a(TEST_ESCAPE
[i
].url
));
855 ok(!strcmp(ret_url
, TEST_ESCAPE
[i
].expecturl
), "Expected \"%s\", but got \"%s\" for \"%s\"\n",
856 TEST_ESCAPE
[i
].expecturl
, ret_url
, TEST_ESCAPE
[i
].url
);
860 static void test_UrlEscapeW(void)
862 WCHAR ret_urlW
[INTERNET_MAX_URL_LENGTH
];
863 WCHAR overwrite
[10] = L
"foo bar";
864 WCHAR empty_string
[] = {0};
870 /* Check error paths */
872 ret
= UrlEscapeW(L
"/test", NULL
, NULL
, URL_ESCAPE_SPACES_ONLY
);
873 ok(ret
== E_INVALIDARG
, "got %lx, expected %lx\n", ret
, E_INVALIDARG
);
876 ret
= UrlEscapeW(L
"/test", NULL
, &size
, URL_ESCAPE_SPACES_ONLY
);
877 ok(ret
== E_INVALIDARG
, "got %lx, expected %lx\n", ret
, E_INVALIDARG
);
878 ok(size
== 0, "got %ld, expected %d\n", size
, 0);
880 ret
= UrlEscapeW(L
"/test", empty_string
, NULL
, URL_ESCAPE_SPACES_ONLY
);
881 ok(ret
== E_INVALIDARG
, "got %lx, expected %lx\n", ret
, E_INVALIDARG
);
884 ret
= UrlEscapeW(L
"/test", empty_string
, &size
, URL_ESCAPE_SPACES_ONLY
);
885 ok(ret
== E_INVALIDARG
, "got %lx, expected %lx\n", ret
, E_INVALIDARG
);
886 ok(size
== 0, "got %ld, expected %d\n", size
, 0);
888 ret
= UrlEscapeW(L
"/test", NULL
, NULL
, URL_ESCAPE_SPACES_ONLY
);
889 ok(ret
== E_INVALIDARG
, "got %lx, expected %lx\n", ret
, E_INVALIDARG
);
892 ret
= UrlEscapeW(L
"/test", NULL
, &size
, URL_ESCAPE_SPACES_ONLY
);
893 ok(ret
== E_INVALIDARG
, "got %lx, expected %lx\n", ret
, E_INVALIDARG
);
894 ok(size
== 1, "got %ld, expected %d\n", size
, 1);
896 ret
= UrlEscapeW(L
"/test", empty_string
, NULL
, URL_ESCAPE_SPACES_ONLY
);
897 ok(ret
== E_INVALIDARG
, "got %lx, expected %lx\n", ret
, E_INVALIDARG
);
900 ret
= UrlEscapeW(L
"/test", empty_string
, &size
, URL_ESCAPE_SPACES_ONLY
);
901 ok(ret
== E_POINTER
, "got %lx, expected %lx\n", ret
, E_POINTER
);
902 ok(size
== 6, "got %ld, expected %d\n", size
, 6);
904 /* Check actual escaping */
906 size
= ARRAY_SIZE(overwrite
);
907 ret
= UrlEscapeW(overwrite
, overwrite
, &size
, URL_ESCAPE_SPACES_ONLY
);
908 ok(ret
== S_OK
, "got %lx, expected S_OK\n", ret
);
909 ok(size
== 9, "got %ld, expected 9\n", size
);
910 ok(!wcscmp(overwrite
, L
"foo%20bar"), "Got unexpected string %s.\n", debugstr_w(overwrite
));
914 ret
= UrlEscapeW(overwrite
, &wc
, &size
, URL_ESCAPE_SPACES_ONLY
);
915 ok(ret
== E_POINTER
, "got %lx, expected %lx\n", ret
, E_POINTER
);
916 ok(size
== 10, "got %ld, expected 10\n", size
);
917 ok(wc
== 127, "String has changed, wc = %d\n", wc
);
919 /* non-ASCII range */
920 size
= ARRAY_SIZE(ret_urlW
);
921 ret
= UrlEscapeW(L
"ftp\x1f\xff\xfa\x2122q/", ret_urlW
, &size
, 0);
922 ok(ret
== S_OK
, "got %lx, expected S_OK\n", ret
);
923 ok(!wcscmp(ret_urlW
, L
"ftp%1F%FF%FA\x2122q/"), "Got unexpected string %s.\n", debugstr_w(ret_urlW
));
925 for (i
= 0; i
< ARRAY_SIZE(TEST_ESCAPE
); i
++) {
927 WCHAR
*urlW
, *expected_urlW
;
929 size
= INTERNET_MAX_URL_LENGTH
;
930 urlW
= GetWideString(TEST_ESCAPE
[i
].url
);
931 expected_urlW
= GetWideString(TEST_ESCAPE
[i
].expecturl
);
932 ret
= UrlEscapeW(urlW
, ret_urlW
, &size
, TEST_ESCAPE
[i
].flags
);
933 ok(ret
== S_OK
, "Got unexpected hr %#lx for %s.\n", ret
, debugstr_w(urlW
));
934 ok(!lstrcmpW(ret_urlW
, expected_urlW
), "Expected %s, but got %s for %s flags %08lx\n",
935 wine_dbgstr_w(expected_urlW
), wine_dbgstr_w(ret_urlW
), wine_dbgstr_w(urlW
), TEST_ESCAPE
[i
].flags
);
936 FreeWideString(urlW
);
937 FreeWideString(expected_urlW
);
940 for (i
= 0; i
< ARRAY_SIZE(TEST_ESCAPEW
); i
++) {
941 WCHAR ret_url
[INTERNET_MAX_URL_LENGTH
];
943 size
= INTERNET_MAX_URL_LENGTH
;
944 ret
= UrlEscapeW(TEST_ESCAPEW
[i
].url
, ret_url
, &size
, TEST_ESCAPEW
[i
].flags
);
945 ok(ret
== S_OK
, "Got unexpected hr %#lx for %s.\n", ret
, debugstr_w(TEST_ESCAPEW
[i
].url
));
946 ok(!wcscmp(ret_url
, TEST_ESCAPEW
[i
].expecturl
)
947 || broken(!wcscmp(ret_url
, TEST_ESCAPEW
[i
].win7url
)),
948 "Expected %s, but got %s for %s.\n", debugstr_w(TEST_ESCAPEW
[i
].expecturl
),
949 debugstr_w(ret_url
), debugstr_w(TEST_ESCAPEW
[i
].url
));
953 struct canonicalize_test
960 static void test_UrlCanonicalizeA(void)
962 CHAR szReturnUrl
[4*INTERNET_MAX_URL_LENGTH
];
963 CHAR longurl
[4*INTERNET_MAX_URL_LENGTH
];
964 char url
[200], expect
[200];
965 unsigned int f
, i
, j
;
970 static const struct canonicalize_test unk_scheme_tests
[] =
972 /* Single and double dots behave as one would expect, with the following
975 * (1) A single or double dot as the first element (the "hostname") is
976 * always emitted as-is.
978 * (2) If a double dot would undo the hostname, it is emitted as-is
981 * (3) If a single or double dot is the last element (either because of
982 * the above rule or because of URL_DONT_SIMPLIFY), a trailing
983 * backslash is appended.
985 * A trailing backslash is always appended after the hostname.
991 {"//a/b", 0, "//a/b"},
992 {"//a/b/", 0, "//a/b/"},
995 {"//./a", 0, "//./a"},
996 {"//././a", 0, "//./a"},
997 {"//a/.", 0, "//a/"},
998 {"//a/./", 0, "//a/"},
999 {"//a/./b", 0, "//a/b"},
1000 {"///./a", 0, "///a"},
1001 {"//a/.b/", 0, "//a/.b/"},
1002 {"//a/b./", 0, "//a/b./"},
1004 {"//..", 0, "//../"},
1005 {"//../", 0, "//../"},
1006 {"//../a", 0, "//../a"},
1007 {"//../a/..", 0, "//../"},
1008 {"//.././..", 0, "//../../"},
1009 {"//../a/../..", 0, "//../../"},
1010 {"//./a/../..", 0, "//./../"},
1011 {"//a/..", 0, "//a/../"},
1012 {"//a/../../b/./c/..", 0, "//a/../../b/"},
1013 {"//a/b/..", 0, "//a/"},
1014 {"//a/b/...", 0, "//a/b/..."},
1015 {"//a/b/../", 0, "//a/"},
1016 {"//a/b/../c", 0, "//a/c"},
1017 {"//a/b/../c/..", 0, "//a/"},
1018 {"//a/b/../c/../..", 0, "//a/../"},
1019 {"//a/b/../../../c", 0, "//a/../../c"},
1020 {"///..", 0, "///../"},
1021 {"////..", 0, "///"},
1022 {"//a/..b/", 0, "//a/..b/"},
1023 {"//a/b../", 0, "//a/b../"},
1024 {"//A/B", 0, "//A/B"},
1026 {"//././a", URL_DONT_SIMPLIFY
, "//././a"},
1027 {"//a/.", URL_DONT_SIMPLIFY
, "//a/./"},
1028 {"//a/./", URL_DONT_SIMPLIFY
, "//a/./"},
1029 {"//a/./b", URL_DONT_SIMPLIFY
, "//a/./b"},
1030 {"///./a", URL_DONT_SIMPLIFY
, "///./a"},
1032 {"//..", URL_DONT_SIMPLIFY
, "//../"},
1033 {"//../", URL_DONT_SIMPLIFY
, "//../"},
1034 {"//../a", URL_DONT_SIMPLIFY
, "//../a"},
1035 {"//../a/..", URL_DONT_SIMPLIFY
, "//../a/../"},
1036 {"//../a/...", URL_DONT_SIMPLIFY
, "//../a/..."},
1037 {"//.././..", URL_DONT_SIMPLIFY
, "//.././../"},
1038 {"//../a/../..", URL_DONT_SIMPLIFY
, "//../a/../../"},
1039 {"//./a/../..", URL_DONT_SIMPLIFY
, "//./a/../../"},
1040 {"//a/..", URL_DONT_SIMPLIFY
, "//a/../"},
1041 {"//a/../../b/./c/..", URL_DONT_SIMPLIFY
, "//a/../../b/./c/../"},
1042 {"//a/b/..", URL_DONT_SIMPLIFY
, "//a/b/../"},
1043 {"//a/b/../", URL_DONT_SIMPLIFY
, "//a/b/../"},
1044 {"//a/b/../c", URL_DONT_SIMPLIFY
, "//a/b/../c"},
1045 {"//a/b/../c/..", URL_DONT_SIMPLIFY
, "//a/b/../c/../"},
1046 {"//a/b/../c/../..", URL_DONT_SIMPLIFY
, "//a/b/../c/../../"},
1047 {"///..", URL_DONT_SIMPLIFY
, "///../"},
1048 {"////..", URL_DONT_SIMPLIFY
, "////../"},
1050 /* After ? or #, dots are not simplified. */
1051 {"//a/b?c/./d", 0, "//a/b?c/./d"},
1052 {"//a/b#c/./d", 0, "//a/b#c/./d"},
1053 {"//a/b#c/.", 0, "//a/b#c/."},
1054 /* ? and # can also be considered a boundary for trailing dots. */
1055 {"//a/b/.?", 0, "//a/b/?"},
1056 {"//a/b/..?", 0, "//a/?"},
1057 {"//a/b/..?", URL_DONT_SIMPLIFY
, "//a/b/../?"},
1058 {"//a/b/.#", 0, "//a/b/#"},
1059 {"//a/b/..#", 0, "//a/#"},
1060 {"//a/b/..#", URL_DONT_SIMPLIFY
, "//a/b/../#"},
1061 {"//a/..?", 0, "//a/../?"},
1062 {"//a/..#", 0, "//a/../#"},
1063 {"//..?", 0, "//../?"},
1064 {"//..#", 0, "//../#"},
1065 {"//?/a/./", 0, "///?/a/./"},
1066 {"//#/a/./", 0, "///#/a/./"},
1067 /* The first ? is reordered before the first #. */
1068 {"//a/b#c?d", 0, "//a/b?d#c"},
1069 {"//a/b?c#d?e", 0, "//a/b?c#d?e"},
1070 {"//a/b#c?d#e", 0, "//a/b?d#e#c"},
1071 {"//a/b#c#d?e", 0, "//a/b?e#c#d"},
1072 {"//a/b#c?d?e", 0, "//a/b?d?e#c"},
1074 /* Backslashes are not treated as path separators. */
1075 {"//a/b\\c/../.\\", 0, "//a/.\\"},
1076 {"//a\\b/../", 0, "//a\\b/../"},
1077 {"//a/b\\../", 0, "//a/b\\../"},
1078 {"//a/b/..\\", 0, "//a/b/..\\"},
1080 /* Whitespace and unsafe characters are not (by default) escaped. */
1081 {"//a/b &c", 0, "//a/b &c"},
1083 /* If one slash is omitted, the rules are much the same, except that
1084 * there is no "hostname". Single dots are always collapsed; double dots
1085 * are collapsed unless they would undo the "scheme". */
1091 {"/././a", 0, "/a"},
1093 {"/a/./", 0, "/a/"},
1094 {"/a/./b", 0, "/a/b"},
1097 {"/../", 0, "/../"},
1098 {"/../a", 0, "/../a"},
1099 {"/../a/..", 0, "/../"},
1101 {"/a/../..", 0, "/../"},
1102 {"/a/b/..", 0, "/a/"},
1103 {"/a/b/../", 0, "/a/"},
1104 {"/a/b/../c", 0, "/a/c"},
1105 {"/a/b/../c/..", 0, "/a/"},
1106 {"/a/b/../c/../..", 0, "/"},
1108 {"/a/b?c/./d", 0, "/a/b?c/./d"},
1109 {"/a/b#c/./d", 0, "/a/b#c/./d"},
1110 {"/a/b#c?d", 0, "/a/b?d#c"},
1112 /* Just as above, backslashes are not treated as path separators. */
1113 {"/a/b\\c/../.\\", 0, "/a/.\\"},
1114 {"/a/b\\/c", 0, "/a/b\\/c"},
1115 {"/a/b\\.c", 0, "/a/b\\.c"},
1116 /* If the first character after the slash is a backslash, it is skipped.
1117 * It is not interpreted as a forward slash.
1118 * The tests above show that this is not due to the backslash being
1119 * interpreted as an escape character. */
1120 {"/\\././a", 0, "/a"},
1121 /* The sequence /\/ does not result in use of the double-slash rules.
1122 * Rather, the resulting // is treated as an empty path element. */
1123 {"/\\/././a", 0, "//a"},
1124 {"/\\/././a/", 0, "//a/"},
1126 {"//a/\\b", 0, "//a/\\b"},
1128 {"/a/b &c", 0, "/a/b &c"},
1130 {"//a/b%20%26c", URL_UNESCAPE
, "//a/b &c"},
1138 const char *expect_ftp
;
1142 /* A set of schemes including http differs from the "default" behaviour
1143 * in the following ways:
1145 * (1) If a double dot would undo the hostname, it is dropped instead.
1147 * (2) If the first element after the hostname is a single or double
1148 * dot, no further dots are simplified.
1150 * (3) Trailing backslashes are not automatically appended after dots.
1155 {"//a/", 0, "//a/"},
1156 {"//a/b", 0, "//a/b"},
1157 {"//a/b/", 0, "//a/b/"},
1159 {"//./", 0, "//./"},
1160 {"//././a/.", 0, "//././a/."},
1161 {"//a/.", 0, "//a/."},
1162 {"//a/./b/./../", 0, "//a/./b/./../"},
1163 {"//a/b/.", 0, "//a/b/"},
1164 {"//a/b/.", URL_DONT_SIMPLIFY
, "//a/b/."},
1165 {"//a/b/./", 0, "//a/b/"},
1166 {"//a/b/./c", 0, "//a/b/c"},
1167 {"///./a", 0, "///./a"},
1168 {"////./a", 0, "////a"},
1170 {"//..", 0, "//../"},
1171 {"//../", 0, "//../"},
1172 {"//../a", 0, "//../a"},
1173 {"//../a/..", 0, "//../"},
1174 {"//../a/../..", 0, "//../"},
1175 {"//./a/../..", 0, "//./"},
1176 {"//a/../", 0, "//a/../"},
1177 {"//a/../../b/./../", 0, "//a/../../b/./../"},
1178 {"//a/.././", 0, "//a/.././"},
1179 {"//a/b/..", 0, "//a/"},
1180 {"//a/b/..", URL_DONT_SIMPLIFY
, "//a/b/.."},
1181 {"//a/b/../", 0, "//a/"},
1182 {"//a/b/.././", 0, "//a/"},
1183 {"//a/b/../c", 0, "//a/c"},
1184 {"//a/b/../c/..", 0, "//a/"},
1185 {"//a/b/../c/../..", 0, "//a/"},
1186 {"//a/b/../../../c", 0, "//a/c"},
1187 {"///a/.", 0, "///a/"},
1188 {"///..", 0, "///.."},
1189 {"////..", 0, "///"},
1190 {"//a//../../..", 0, "//a/"},
1192 {"//a/b?c/./d", 0, "//a/b?c/./d"},
1193 {"//a/b#c/./d", 0, "//a/b#c/./d"},
1194 {"//a/b#c?d", 0, "//a/b#c?d"},
1195 {"//a/b?c#d", 0, "//a/b?c#d"},
1197 {"//localhost/b", 0, "//localhost/b"},
1199 /* Most of these schemes translates backslashes to forward slashes,
1200 * including the initial pair, and interpret them appropriately.
1202 * A few schemes, including ftp, don't translate backslashes to forward
1203 * slashes, but still interpret them as path separators, with the
1204 * exception that the hostname must end in a forward slash. */
1206 {"//a/b\\", 0, "//a/b/", "//a/b\\"},
1207 {"//a/b\\./c", 0, "//a/b/c", "//a/b\\c"},
1208 {"//a/b/.\\c", 0, "//a/b/c"},
1209 {"//a/b\\c/../.\\", 0, "//a/b/", "//a/b\\"},
1210 {"//a\\b", 0, "//a/b", "//a\\b/"},
1211 {"//a\\b/..", 0, "//a/", "//a\\b/.."},
1212 {"//a/b\\c", 0, "//a/b/c", "//a/b\\c"},
1213 {"/\\a\\..", 0, "//a/..", "/\\a\\../"},
1214 {"\\/a\\..", 0, "//a/..", "\\/a\\../"},
1216 {"//a/b &c", 0, "//a/b &c"},
1218 /* If one or both slashes is missing, the portion after the colon is
1219 * treated like a normal path, without a hostname. Single and double
1220 * dots are always collapsed, and double dots which would rewind past
1221 * the scheme are dropped instead. */
1228 {"a/../..", URL_DONT_SIMPLIFY
, "a/../.."},
1239 {"a/b?c/.\\d", 0, "a/b?c/.\\d"},
1240 {"a/b#c/.\\d", 0, "a/b#c/.\\d"},
1242 {"a\\b\\", 0, "a/b/", "a\\b\\"},
1244 {"a/b &c", 0, "a/b &c"},
1246 {"/foo/bar/baz", URL_ESCAPE_SEGMENT_ONLY
, "/foo/bar/baz"},
1247 {"/foo/bar/baz?a#b", URL_ESCAPE_SEGMENT_ONLY
, "/foo/bar/baz?a#b"},
1249 {"//www.winehq.org/tests\n", URL_ESCAPE_SPACES_ONLY
| URL_ESCAPE_UNSAFE
, "//www.winehq.org/tests"},
1250 {"//www.winehq.org/tests\r", URL_ESCAPE_SPACES_ONLY
| URL_ESCAPE_UNSAFE
, "//www.winehq.org/tests"},
1251 {"//www.winehq.org/tests/foo bar", URL_ESCAPE_SPACES_ONLY
| URL_DONT_ESCAPE_EXTRA_INFO
, "//www.winehq.org/tests/foo%20bar"},
1252 {"//www.winehq.org/tests/foo%20bar", 0, "//www.winehq.org/tests/foo%20bar"},
1253 {"//www.winehq.org/tests/foo%20bar", URL_UNESCAPE
, "//www.winehq.org/tests/foo bar"},
1254 {"//www.winehq.org/%E6%A1%9C.html", 0, "//www.winehq.org/%E6%A1%9C.html"},
1257 static const struct canonicalize_test opaque_tests
[] =
1259 /* Opaque protocols, predictably, do not modify the portion after the
1261 {"//a/b/./c/../d\\e", 0, "//a/b/./c/../d\\e"},
1262 {"/a/b/./c/../d\\e", 0, "/a/b/./c/../d\\e"},
1263 {"a/b/./c/../d\\e", 0, "a/b/./c/../d\\e"},
1265 {"//a/b &c", 0, "//a/b &c"},
1266 {"//a/b%20%26c", URL_UNESCAPE
, "//a/b &c"},
1269 static const struct canonicalize_test file_tests
[] =
1271 /* file:// is almost identical to http://, except that a URL beginning
1272 * with file://// (four or more slashes) is stripped down to two
1273 * slashes. The first non-empty element is interpreted as a hostname;
1274 * and the rest follows the usual rules.
1276 * The intent here is probably to detect UNC paths, although it's
1277 * unclear why an arbitrary number of slashes are skipped in that case.
1280 {"file://", 0, "file:///"},
1281 {"file://a", 0, "file://a/"},
1282 {"file://a/", 0, "file://a/"},
1283 {"file://a//", 0, "file://a//"},
1284 {"file://a/b", 0, "file://a/b"},
1285 {"file://a/b/", 0, "file://a/b/"},
1286 {"file://.", 0, "file://./"},
1287 {"file://./", 0, "file://./"},
1288 {"file://././a/.", 0, "file://././a/."},
1289 {"file://a/.", 0, "file://a/."},
1290 {"file://a/./b/./../", 0, "file://a/./b/./../"},
1291 {"file://a/b/.", 0, "file://a/b/"},
1292 {"file://a/b/.", URL_DONT_SIMPLIFY
, "file://a/b/."},
1293 {"file://a/b/./", 0, "file://a/b/"},
1294 {"file://a/b/./c", 0, "file://a/b/c"},
1295 {"file:///./a", 0, "file:///./a"},
1296 {"file:////./a", 0, "file://./a"},
1298 {"file://..", 0, "file://../"},
1299 {"file://../", 0, "file://../"},
1300 {"file://../a", 0, "file://../a"},
1301 {"file://../a/..", 0, "file://../"},
1302 {"file://../a/../..", 0, "file://../"},
1303 {"file://./a/../..", 0, "file://./"},
1304 {"file://a/../", 0, "file://a/../"},
1305 {"file://a/../../b/./../", 0, "file://a/../../b/./../"},
1306 {"file://a/.././", 0, "file://a/.././"},
1307 {"file://a/b/..", 0, "file://a/"},
1308 {"file://a/b/../", 0, "file://a/"},
1309 {"file://a/b/.././", 0, "file://a/"},
1310 {"file://a/b/../c", 0, "file://a/c"},
1311 {"file://a/b/../c/..", 0, "file://a/"},
1312 {"file://a/b/../c/../..", 0, "file://a/"},
1313 {"file://a/b/../../../c", 0, "file://a/c"},
1314 {"file:///.", 0, "file:///."},
1315 {"file:///..", 0, "file:///.."},
1316 {"file:///a/.", 0, "file:///a/"},
1318 {"file:////", 0, "file:///"},
1319 {"file:////a/./b/../c", 0, "file://a/./b/../c"},
1320 {"file://///a/./b/../c", 0, "file://a/./b/../c"},
1321 {"file://////a/./b/../c", 0, "file://a/./b/../c"},
1322 {"file:////a/b/./../c", 0, "file://a/c"},
1323 {"file:////a/b/./../..", 0, "file://a/"},
1324 {"file://///a/b/./../c", 0, "file://a/c"},
1325 {"file://////a/b/./../c", 0, "file://a/c"},
1326 {"file:////.", 0, "file://./"},
1327 {"file:////..", 0, "file://../"},
1328 {"file:////./b/./../c", 0, "file://./c"},
1329 {"file:////./b/./../..", 0, "file://./"},
1330 {"file://///./b/./../c", 0, "file://./c"},
1331 {"file://////./b/./../c", 0, "file://./c"},
1333 /* Drive-like paths get an extra slash (i.e. an empty hostname, to
1334 * signal that the host is the local machine). The drive letter is
1335 * treated as the path root. */
1336 {"file://a:", 0, "file:///a:"},
1337 {"file://a:/b", 0, "file:///a:/b"},
1338 {"file://a:/b/../..", 0, "file:///a:/"},
1339 {"file://a:/./../..", 0, "file:///a:/./../.."},
1340 {"file://a|/b", 0, "file:///a|/b"},
1341 {"file://ab:/c", 0, "file://ab:/c"},
1342 {"file:///a:", 0, "file:///a:"},
1343 {"file:////a:", 0, "file:///a:"},
1344 {"file://///a:", 0, "file:///a:"},
1345 {"file://host/a:/b/../..", 0, "file://host/a:/"},
1347 /* URL_FILE_USE_PATHURL (and URL_WININET_COMPATIBILITY) have their own
1350 * (1) Dot processing works exactly like the "unknown scheme" rules,
1351 * instead of the file/http rules demonstrated above.
1353 * (2) Some number of backslashes is appended after the two forward
1354 * slashes. The number basically corresponds to the detected path
1355 * type (two for a remote path, one for a local path, none for a
1356 * local drive path). A local path is one where the hostname is
1357 * empty or "localhost". If all path elements are empty then no
1358 * backslashes are appended.
1361 {"file://", URL_FILE_USE_PATHURL
, "file://"},
1362 {"file://a", URL_FILE_USE_PATHURL
, "file://\\\\a"},
1363 {"file://a/", URL_FILE_USE_PATHURL
, "file://\\\\a"},
1364 {"file://a//", URL_FILE_USE_PATHURL
, "file://\\\\a\\\\"},
1365 {"file://a/b", URL_FILE_USE_PATHURL
, "file://\\\\a\\b"},
1366 {"file://a//b", URL_FILE_USE_PATHURL
, "file://\\\\a\\\\b"},
1367 {"file://a/.", URL_FILE_USE_PATHURL
, "file://\\\\a\\"},
1368 {"file://a/../../b/./c/..", URL_FILE_USE_PATHURL
, "file://\\\\a\\..\\..\\b\\"},
1369 {"file://./../../b/./c/..", URL_FILE_USE_PATHURL
, "file://\\\\.\\..\\..\\b\\"},
1370 {"file://../../../b/./c/..", URL_FILE_USE_PATHURL
, "file://\\\\..\\..\\..\\b\\"},
1371 {"file://a/b/.", URL_FILE_USE_PATHURL
, "file://\\\\a\\b\\"},
1372 {"file://a/b/.", URL_FILE_USE_PATHURL
| URL_DONT_SIMPLIFY
, "file://\\\\a\\b\\.\\"},
1373 {"file://a/b/../../../c", URL_FILE_USE_PATHURL
, "file://\\\\a\\..\\..\\c"},
1375 {"file:///", URL_FILE_USE_PATHURL
, "file://"},
1376 {"file:///.", URL_FILE_USE_PATHURL
, "file://\\"},
1377 {"file:///..", URL_FILE_USE_PATHURL
, "file://\\..\\"},
1378 {"file:///../../b/./c/..", URL_FILE_USE_PATHURL
, "file://\\..\\..\\b\\"},
1379 {"file:///a/b/./c/..", URL_FILE_USE_PATHURL
, "file://\\a\\b\\"},
1381 {"file:////", URL_FILE_USE_PATHURL
, "file://"},
1382 {"file:////.", URL_FILE_USE_PATHURL
, "file://\\\\."},
1383 {"file:////a/./b/../c", URL_FILE_USE_PATHURL
, "file://\\\\a\\c"},
1384 {"file://///", URL_FILE_USE_PATHURL
, "file://"},
1385 {"file://///a/./b/../c", URL_FILE_USE_PATHURL
, "file://\\\\a\\c"},
1387 {"file://a:", URL_FILE_USE_PATHURL
, "file://a:"},
1388 {"file://a:/", URL_FILE_USE_PATHURL
, "file://a:\\"},
1389 {"file://a:/b", URL_FILE_USE_PATHURL
, "file://a:\\b"},
1390 {"file://a:/b/../..", URL_FILE_USE_PATHURL
, "file://a:\\..\\"},
1391 {"file://a|/b", URL_FILE_USE_PATHURL
, "file://a|\\b"},
1392 {"file:///a:", URL_FILE_USE_PATHURL
, "file://a:"},
1393 {"file:////a:", URL_FILE_USE_PATHURL
, "file://a:"},
1395 /* URL_WININET_COMPATIBILITY is almost identical, but ensures a trailing
1396 * backslash in two cases:
1398 * (1) if all path elements are empty,
1400 * (2) if the path consists of just the hostname.
1403 {"file://", URL_WININET_COMPATIBILITY
, "file://\\"},
1404 {"file://a", URL_WININET_COMPATIBILITY
, "file://\\\\a\\"},
1405 {"file://a/", URL_WININET_COMPATIBILITY
, "file://\\\\a\\"},
1406 {"file://a//", URL_WININET_COMPATIBILITY
, "file://\\\\a\\\\"},
1407 {"file://a/b", URL_WININET_COMPATIBILITY
, "file://\\\\a\\b"},
1408 {"file://a//b", URL_WININET_COMPATIBILITY
, "file://\\\\a\\\\b"},
1409 {"file://a/.", URL_WININET_COMPATIBILITY
, "file://\\\\a\\"},
1410 {"file://a/../../b/./c/..", URL_WININET_COMPATIBILITY
, "file://\\\\a\\..\\..\\b\\"},
1411 {"file://./../../b/./c/..", URL_WININET_COMPATIBILITY
, "file://\\\\.\\..\\..\\b\\"},
1412 {"file://../../../b/./c/..", URL_WININET_COMPATIBILITY
, "file://\\\\..\\..\\..\\b\\"},
1413 {"file://a/b/../../../c", URL_WININET_COMPATIBILITY
, "file://\\\\a\\..\\..\\c"},
1415 {"file:///", URL_WININET_COMPATIBILITY
, "file://\\"},
1416 {"file:///.", URL_WININET_COMPATIBILITY
, "file://\\"},
1417 {"file:///..", URL_WININET_COMPATIBILITY
, "file://\\..\\"},
1418 {"file:///../../b/./c/..", URL_WININET_COMPATIBILITY
, "file://\\..\\..\\b\\"},
1419 {"file:///a/b/./c/..", URL_WININET_COMPATIBILITY
, "file://\\a\\b\\"},
1421 {"file:////", URL_WININET_COMPATIBILITY
, "file://\\"},
1422 {"file:////.", URL_WININET_COMPATIBILITY
, "file://\\\\.\\"},
1423 {"file:////a/./b/../c", URL_WININET_COMPATIBILITY
, "file://\\\\a\\c"},
1424 {"file://///", URL_WININET_COMPATIBILITY
, "file://\\"},
1425 {"file://///a/./b/../c", URL_WININET_COMPATIBILITY
, "file://\\\\a\\c"},
1427 {"file://a:", URL_WININET_COMPATIBILITY
, "file://a:"},
1429 {"file://", URL_FILE_USE_PATHURL
| URL_WININET_COMPATIBILITY
, "file://"},
1431 {"file://localhost/a", 0, "file://localhost/a"},
1432 {"file://localhost//a", 0, "file://localhost//a"},
1433 {"file://localhost/a:", 0, "file://localhost/a:"},
1434 {"file://localhost/a:/b/../..", 0, "file://localhost/a:/"},
1435 {"file://localhost/a:/./../..", 0, "file://localhost/a:/./../.."},
1436 {"file://localhost", URL_FILE_USE_PATHURL
, "file://"},
1437 {"file://localhost/", URL_FILE_USE_PATHURL
, "file://"},
1438 {"file://localhost/b", URL_FILE_USE_PATHURL
, "file://\\b"},
1439 {"file://127.0.0.1/b", URL_FILE_USE_PATHURL
, "file://\\\\127.0.0.1\\b"},
1440 {"file://localhost//b", URL_FILE_USE_PATHURL
, "file://\\b"},
1441 {"file://localhost///b", URL_FILE_USE_PATHURL
, "file://\\\\b"},
1442 {"file:///localhost/b", URL_FILE_USE_PATHURL
, "file://\\localhost\\b"},
1443 {"file:////localhost/b", URL_FILE_USE_PATHURL
, "file://\\b"},
1444 {"file://///localhost/b", URL_FILE_USE_PATHURL
, "file://\\b"},
1445 {"file://localhost/a:", URL_FILE_USE_PATHURL
, "file://a:"},
1446 {"file://localhost/a:/b/../..", URL_FILE_USE_PATHURL
, "file://a:\\..\\"},
1447 {"file://localhost?a/b", URL_FILE_USE_PATHURL
, "file://"},
1448 {"file://localhost#a/b", URL_FILE_USE_PATHURL
, "file://\\\\localhost#a/b"},
1449 {"file://localhostq", URL_FILE_USE_PATHURL
, "file://\\\\localhostq"},
1451 {"file://localhost", URL_WININET_COMPATIBILITY
, "file://\\"},
1452 {"file://localhost/", URL_WININET_COMPATIBILITY
, "file://\\"},
1453 {"file://localhost/b", URL_WININET_COMPATIBILITY
, "file://\\b"},
1454 {"file://localhost//b", URL_WININET_COMPATIBILITY
, "file://\\b"},
1455 {"file://127.0.0.1/b", URL_WININET_COMPATIBILITY
, "file://\\\\127.0.0.1\\b"},
1456 {"file://localhost/a:", URL_WININET_COMPATIBILITY
, "file://a:"},
1457 {"file://localhost?a/b", URL_WININET_COMPATIBILITY
, "file://\\?a/b"},
1458 {"file://localhost#a/b", URL_WININET_COMPATIBILITY
, "file://\\\\localhost#a/b"},
1460 /* # has some weird behaviour:
1462 * - Dot processing happens normally after it, including rewinding past
1463 * the #. It's not treated as a path separator for the purposes of
1466 * - However, if neither file flag is used, and the first character
1467 * after the hostname (plus an optional slash) is a hash, no dot
1468 * processing takes place.
1470 * - If the previous path segment ends in .htm or .html, the rest of
1471 * the URL is emitted verbatim (no dot or slash canonicalization).
1472 * This does not apply to the hostname. If URL_FILE_USE_PATHURL is
1473 * used, though, the rest of the URL including the # is omitted.
1475 * - It is treated as a path terminator for dots, but only if neither
1476 * file flag is used. It does not begin a path element.
1478 * - If there is a # anywhere in the output string (and the string
1479 * doesn't fall under the .html exception), all subsequent slashes
1480 * are converted to forward slashes instead of backslashes.
1481 * This means that rewinding past the hash will revert to backslashes.
1482 * (This of course only affects the case where file flags are used;
1483 * if no file flags are used then slashes are converted to forward
1486 {"file://a/b#c/../d\\e", 0, "file://a/d/e"},
1487 {"file://a/b#c/./d\\e", 0, "file://a/b#c/d/e"},
1488 {"file://a/b.htm#c/../d\\e", 0, "file://a/b.htm#c/../d\\e"},
1489 {"file://a/b.html#c/../d\\e", 0, "file://a/b.html#c/../d\\e"},
1490 {"file://a/b.hTmL#c/../d\\e", 0, "file://a/b.hTmL#c/../d\\e"},
1491 {"file://a/b.xhtml#c/../d\\e", 0, "file://a/d/e"},
1492 {"file://a/b.php#c/../d\\e", 0, "file://a/d/e"},
1493 {"file://a/b.asp#c/../d\\e", 0, "file://a/d/e"},
1494 {"file://a/b.aspx#c/../d\\e", 0, "file://a/d/e"},
1495 {"file://a/b.ht#c/../d\\e", 0, "file://a/d/e"},
1496 {"file://a/b.txt#c/../d\\e", 0, "file://a/d/e"},
1497 {"file://a/b.htmlq#c/../d\\e", 0, "file://a/d/e"},
1498 {"file://a/b.html/q#c/../d\\e", 0, "file://a/b.html/d/e"},
1499 {"file://a/.html#c/../d\\e", 0, "file://a/.html#c/../d\\e"},
1500 {"file://a/html#c/../d\\e", 0, "file://a/d/e"},
1501 {"file://a/b#c/./d.html#e/../f", 0, "file://a/b#c/d.html#e/../f"},
1502 {"file://a.html#/b/../c", 0, "file://a.html#/c"},
1503 {"file://a/b#c/../d/e", URL_FILE_USE_PATHURL
, "file://\\\\a\\d\\e"},
1504 {"file://a/b#c/./d/e", URL_FILE_USE_PATHURL
, "file://\\\\a\\b#c/d/e"},
1505 {"file://a/b.html#c/../d\\e", URL_FILE_USE_PATHURL
, "file://\\\\a\\b.html"},
1506 {"file://a/b.html#c/../d\\e", URL_FILE_USE_PATHURL
| URL_WININET_COMPATIBILITY
, "file://\\\\a\\b.html"},
1507 {"file://a/b#c/../d/e", URL_WININET_COMPATIBILITY
, "file://\\\\a\\d\\e"},
1508 {"file://a/b#c/./d/e", URL_WININET_COMPATIBILITY
, "file://\\\\a\\b#c/d/e"},
1509 {"file://a/b.html#c/../d\\e", URL_WININET_COMPATIBILITY
, "file://\\\\a\\b.html#c/../d\\e"},
1510 {"file://a/c#/../d", 0, "file://a/d"},
1511 {"file://a/c#/../d", URL_FILE_USE_PATHURL
, "file://\\\\a\\d"},
1512 {"file://a/c#/../d", URL_WININET_COMPATIBILITY
, "file://\\\\a\\d"},
1513 {"file://a/#c/../d\\e", 0, "file://a/#c/../d\\e"},
1514 {"file://a/#c/../d/e", URL_FILE_USE_PATHURL
, "file://\\\\a\\d\\e"},
1515 {"file://a/#c/../d/e", URL_WININET_COMPATIBILITY
, "file://\\\\a\\d\\e"},
1516 {"file://a//#c/../d", 0, "file://a//#c/../d"},
1517 {"file://a//#c/../d", URL_FILE_USE_PATHURL
, "file://\\\\a\\\\d"},
1518 {"file://a//#c/../d", URL_WININET_COMPATIBILITY
, "file://\\\\a\\\\d"},
1519 {"file://a/\\#c/../d", 0, "file://a//#c/../d"},
1520 {"file://a///#c/../d", 0, "file://a///d"},
1521 {"file://a/b/#c/../d", 0, "file://a/b/d"},
1522 {"file://a/b/.#c", 0, "file://a/b/#c"},
1523 {"file://a/b/..#c", 0, "file://a/#c"},
1524 {"file://a/b/.#c", URL_FILE_USE_PATHURL
, "file://\\\\a\\b\\.#c"},
1525 {"file://a/b/..#c", URL_FILE_USE_PATHURL
, "file://\\\\a\\b\\..#c"},
1526 {"file://a/b/.#c", URL_WININET_COMPATIBILITY
, "file://\\\\a\\b\\.#c"},
1527 {"file://a/b/..#c", URL_WININET_COMPATIBILITY
, "file://\\\\a\\b\\..#c"},
1528 {"file://a/b#../c", 0, "file://a/b#../c"},
1529 {"file://a/b/#../c", 0, "file://a/b/#../c"},
1530 {"file://a/b#../c", URL_FILE_USE_PATHURL
, "file://\\\\a\\b#../c"},
1531 {"file://a/b#../c", URL_WININET_COMPATIBILITY
, "file://\\\\a\\b#../c"},
1532 {"file://#/b\\./", 0, "file://#/b/"},
1533 {"file://#/./b\\./", 0, "file://#/./b/./"},
1534 {"file://#/b\\./", URL_FILE_USE_PATHURL
, "file://\\\\#/b/"},
1535 {"file://#/b\\./", URL_WININET_COMPATIBILITY
, "file://\\\\#/b/"},
1536 {"file://a#/b\\./", 0, "file://a#/b/"},
1537 {"file://a#/./b\\./", 0, "file://a#/./b/./"},
1538 {"file://a#/b\\./", URL_FILE_USE_PATHURL
, "file://\\\\a#/b/"},
1539 {"file://a#/b\\./", URL_WININET_COMPATIBILITY
, "file://\\\\a#/b/"},
1540 {"file://a#/b\\./", URL_FILE_USE_PATHURL
| URL_DONT_SIMPLIFY
, "file://\\\\a#/b/./"},
1541 {"file://a#/b\\.", URL_FILE_USE_PATHURL
| URL_DONT_SIMPLIFY
, "file://\\\\a#/b/./"},
1542 {"file://a#/b/../../", 0, "file://a#/"},
1544 /* ? is similar, with the following exceptions:
1546 * - URLs ending in .htm(l) are not treated specially.
1548 * - With URL_FILE_USE_PATHURL, the rest of the URL including the ? is
1549 * just omitted (much like the .html case above).
1551 * - With URL_WININET_COMPATIBILITY, the rest of the URL is always
1552 * emitted verbatim (completely opaque, like other schemes).
1555 {"file://a/b?c/../d\\e", 0, "file://a/d/e"},
1556 {"file://a/b.html?c/../d\\e", 0, "file://a/d/e"},
1557 {"file://a/b?c/../d\\e", URL_FILE_USE_PATHURL
, "file://\\\\a\\b"},
1558 {"file://a/b.html?c/../d\\e", URL_FILE_USE_PATHURL
, "file://\\\\a\\b.html"},
1559 {"file://a/b?c/../d\\e", URL_WININET_COMPATIBILITY
, "file://\\\\a\\b?c/../d\\e"},
1560 {"file://a/b.html?c/../d\\e", URL_WININET_COMPATIBILITY
, "file://\\\\a\\b.html?c/../d\\e"},
1561 {"file://a/b?c/../d", URL_FILE_USE_PATHURL
| URL_WININET_COMPATIBILITY
, "file://\\\\a\\b"},
1562 {"file://a/?c/../d", 0, "file://a/?c/../d"},
1563 {"file://a/?c/../d", URL_FILE_USE_PATHURL
, "file://\\\\a"},
1564 {"file://a/?c/../d", URL_WININET_COMPATIBILITY
, "file://\\\\a\\?c/../d"},
1565 {"file://a//?c/../d", 0, "file://a//?c/../d"},
1566 {"file://a//?c/../d", URL_FILE_USE_PATHURL
, "file://\\\\a\\\\"},
1567 {"file://a//?c/../d", URL_WININET_COMPATIBILITY
, "file://\\\\a\\\\?c/../d"},
1568 {"file://a/\\?c/../d", 0, "file://a//?c/../d"},
1569 {"file://a///?c/../d", 0, "file://a///d"},
1570 {"file://a/b/?c/../d", 0, "file://a/b/d"},
1571 {"file://a/b/.?c", 0, "file://a/b/?c"},
1572 {"file://a/b/..?c", 0, "file://a/?c"},
1573 {"file://a/b/.?c", URL_FILE_USE_PATHURL
, "file://\\\\a\\b\\"},
1574 {"file://a/b/..?c", URL_FILE_USE_PATHURL
, "file://\\\\a\\"},
1575 {"file://a/b/.?c", URL_WININET_COMPATIBILITY
, "file://\\\\a\\b\\?c"},
1576 {"file://a/b/..?c", URL_WININET_COMPATIBILITY
, "file://\\\\a\\?c"},
1577 {"file://?/a\\./", 0, "file://?/a/"},
1578 {"file://?/./a\\./", 0, "file://?/./a/./"},
1579 {"file://?/a\\./", URL_FILE_USE_PATHURL
, "file://"},
1580 {"file://?/a\\./", URL_WININET_COMPATIBILITY
, "file://\\?/a\\./"},
1581 {"file://a?/a\\./", 0, "file://a?/a/"},
1582 {"file://a?/./a\\./", 0, "file://a?/./a/./"},
1583 {"file://a?/a\\./", URL_FILE_USE_PATHURL
, "file://\\\\a"},
1584 {"file://a?/a\\./", URL_WININET_COMPATIBILITY
, "file://\\\\a\\?/a\\./"},
1586 {"file://a/b.html?c#d/..", 0, "file://a/"},
1587 {"file://a/b.html?c.html#d/..", 0, "file://a/b.html?c.html#d/.."},
1588 {"file://a/b?\\#c\\d", 0, "file://a/b?/#c/d"},
1589 {"file://a/b?\\#c\\d", URL_WININET_COMPATIBILITY
, "file://\\\\a\\b?\\#c\\d"},
1590 {"file://a/b?\\#c\\d", URL_FILE_USE_PATHURL
, "file://\\\\a\\b"},
1591 {"file://a/b#\\?c\\d", 0, "file://a/b#/?c/d"},
1592 {"file://a/b#\\?c\\d", URL_WININET_COMPATIBILITY
, "file://\\\\a\\b#/?c\\d"},
1593 {"file://a/b#\\?c\\d", URL_FILE_USE_PATHURL
, "file://\\\\a\\b#/"},
1594 {"file://a/b.html#c?d", URL_WININET_COMPATIBILITY
, "file://\\\\a\\b.html?d#c"},
1596 /* file: treats backslashes like forward slashes, including the
1598 {"file://a/b\\", 0, "file://a/b/"},
1599 {"file://a/b\\c/../.\\", 0, "file://a/b/"},
1600 {"file://a\\b", 0, "file://a/b"},
1601 {"file:/\\a\\..", 0, "file://a/.."},
1602 {"file:\\/a\\..", 0, "file://a/.."},
1603 {"file:\\\\a\\b", URL_FILE_USE_PATHURL
, "file://\\\\a\\b"},
1604 {"file:\\\\a\\b", URL_WININET_COMPATIBILITY
, "file://\\\\a\\b"},
1605 {"file:\\///a/./b/../c", 0, "file://a/./b/../c"},
1606 {"file:/\\//a/./b/../c", 0, "file://a/./b/../c"},
1607 {"file://\\/a/./b/../c", 0, "file://a/./b/../c"},
1608 {"file:///\\a/./b/../c", 0, "file://a/./b/../c"},
1610 {"file://a/b &c", 0, "file://a/b &c"},
1611 {"file://a/b &c", URL_FILE_USE_PATHURL
, "file://\\\\a\\b &c"},
1612 {"file://a/b &c", URL_WININET_COMPATIBILITY
, "file://\\\\a\\b &c"},
1613 {"file://a/b !\"$%&'()*+,-:;<=>@[]^_`{|}~c", URL_ESCAPE_UNSAFE
, "file://a/b%20!%22$%%26'()*+,-:;%3C=%3E@%5B%5D%5E_%60%7B%7C%7D~c"},
1614 {"file://a/b%20%26c", 0, "file://a/b%20%26c"},
1615 {"file://a/b%20%26c", URL_FILE_USE_PATHURL
, "file://\\\\a\\b &c"},
1616 {"file://a/b%20%26c", URL_WININET_COMPATIBILITY
, "file://\\\\a\\b%20%26c"},
1618 /* Omitting one slash behaves as if the URL had been written with an
1619 * empty hostname, and the output adds two slashes as such. */
1621 {"file:/", 0, "file:///"},
1622 {"file:/a", 0, "file:///a"},
1623 {"file:/./a", 0, "file:///./a"},
1624 {"file:/../a/..", 0, "file:///../a/.."},
1625 {"file:/./..", 0, "file:///./.."},
1626 {"file:/a/.", 0, "file:///a/"},
1627 {"file:/a/../..", 0, "file:///"},
1628 {"file:/a:", 0, "file:///a:"},
1629 {"file:/a:/b/../..", 0, "file:///a:/"},
1631 /* The same applies to the flags. */
1633 {"file:/", URL_FILE_USE_PATHURL
, "file://"},
1634 {"file:/a", URL_FILE_USE_PATHURL
, "file://\\a"},
1635 {"file:/.", URL_FILE_USE_PATHURL
, "file://\\"},
1636 {"file:/./a", URL_FILE_USE_PATHURL
, "file://\\a"},
1637 {"file:/../a", URL_FILE_USE_PATHURL
, "file://\\..\\a"},
1638 {"file:/a/../..", URL_FILE_USE_PATHURL
, "file://\\..\\"},
1639 {"file:/a/.", URL_FILE_USE_PATHURL
| URL_DONT_SIMPLIFY
, "file://\\a\\.\\"},
1640 {"file:/a:", URL_FILE_USE_PATHURL
, "file://a:"},
1641 {"file:/a:/b/../..", URL_FILE_USE_PATHURL
, "file://a:\\..\\"},
1643 {"file:/", URL_WININET_COMPATIBILITY
, "file://\\"},
1644 {"file:/a", URL_WININET_COMPATIBILITY
, "file://\\a"},
1645 {"file:/.", URL_WININET_COMPATIBILITY
, "file://\\"},
1646 {"file:/a:", URL_WININET_COMPATIBILITY
, "file://a:"},
1648 {"file:/a/b#c/../d", 0, "file:///a/d"},
1649 {"file:/a/b?c/../d", 0, "file:///a/d"},
1651 {"file:/a\\b\\", 0, "file:///a/b/"},
1652 {"file:\\a/b/", 0, "file:///a/b/"},
1653 {"file:\\a\\b", URL_FILE_USE_PATHURL
, "file://\\a\\b"},
1654 {"file:\\a\\b", URL_WININET_COMPATIBILITY
, "file://\\a\\b"},
1656 {"file:/a/b &c", 0, "file:///a/b &c"},
1658 /* Omitting both slashes causes all dots to be collapsed, in the same
1659 * way as bare http. */
1661 {"file:a", 0, "file:a"},
1662 {"file:a/", 0, "file:a/"},
1663 {"file:a/.", 0, "file:a/"},
1664 {"file:a/..", 0, "file:"},
1665 {"file:a/../..", 0, "file:"},
1666 {"file:", 0, "file:"},
1667 {"file:.", 0, "file:"},
1668 {"file:..", 0, "file:"},
1669 {"file:./", 0, "file:"},
1670 {"file:../", 0, "file:"},
1672 {"file:a:", 0, "file:///a:"},
1674 /* URL_FILE_USE_PATHURL treats everything here as a local (relative?)
1675 * path. In the case that the path resolves to the current directory
1676 * a single backslash is emitted. */
1677 {"file:", URL_FILE_USE_PATHURL
, "file://"},
1678 {"file:a", URL_FILE_USE_PATHURL
, "file://a"},
1679 {"file:a/.", URL_FILE_USE_PATHURL
, "file://a\\"},
1680 {"file:a/../..", URL_FILE_USE_PATHURL
, "file://..\\"},
1681 {"file:./a", URL_FILE_USE_PATHURL
, "file://a"},
1682 {"file:../a", URL_FILE_USE_PATHURL
, "file://..\\a"},
1683 {"file:a/.", URL_FILE_USE_PATHURL
| URL_DONT_SIMPLIFY
, "file://a\\.\\"},
1684 {"file:a:", URL_FILE_USE_PATHURL
, "file://a:"},
1686 /* URL_WININET_COMPATIBILITY doesn't emit a double slash. */
1687 {"file:", URL_WININET_COMPATIBILITY
, "file:"},
1688 {"file:a", URL_WININET_COMPATIBILITY
, "file:a"},
1689 {"file:./a", URL_WININET_COMPATIBILITY
, "file:a"},
1690 {"file:../a", URL_WININET_COMPATIBILITY
, "file:..\\a"},
1691 {"file:../b/./c/../d", URL_WININET_COMPATIBILITY
| URL_DONT_SIMPLIFY
, "file:..\\b\\.\\c\\..\\d"},
1692 {"file:a:", URL_WININET_COMPATIBILITY
, "file://a:"},
1694 {"file:a/b?c/../d", 0, "file:a/d"},
1695 {"file:a/b#c/../d", 0, "file:a/d"},
1697 {"file:a\\b\\", 0, "file:a/b/"},
1699 {"file:a/b &c", 0, "file:a/b &c"},
1701 {"fIlE://A/B", 0, "file://A/B"},
1702 {"fIlE://A/B", URL_FILE_USE_PATHURL
, "file://\\\\A\\B"},
1703 {"fIlE://A/B", URL_WININET_COMPATIBILITY
, "file://\\\\A\\B"},
1704 {"fIlE:A:/B", 0, "file:///A:/B"},
1705 {"fIlE:A:/B", URL_FILE_USE_PATHURL
, "file://A:\\B"},
1706 {"fIlE:A:/B", URL_WININET_COMPATIBILITY
, "file://A:\\B"},
1707 {"fIlE://lOcAlHoSt/B", 0, "file://lOcAlHoSt/B"},
1708 {"fIlE://lOcAlHoSt/B", URL_FILE_USE_PATHURL
, "file://\\B"},
1710 /* Drive paths are automatically converted to file paths. Dots are
1711 * collapsed unless the first segment after q: or q:/ is a dot. */
1713 {"q:a", 0, "file:///q:a"},
1714 {"q:a/.", 0, "file:///q:a/"},
1715 {"q:a/..", 0, "file:///q:"},
1716 {"q:a/../..", 0, "file:///q:"},
1717 {"q:./a/..", 0, "file:///q:./a/.."},
1718 {"q:../a/..", 0, "file:///q:../a/.."},
1719 {"q:/", 0, "file:///q:/"},
1720 {"q:/a", 0, "file:///q:/a"},
1721 {"q:/a/.", 0, "file:///q:/a/"},
1722 {"q:/a/..", 0, "file:///q:/"},
1723 {"q:/./a/..", 0, "file:///q:/./a/.."},
1724 {"q:/../a/..", 0, "file:///q:/../a/.."},
1725 {"q://./a", 0, "file:///q://a"},
1726 {"q://../a", 0, "file:///q:/a"},
1728 /* File flags use the "unknown scheme" rules, and the root of the path
1729 * is the first slash. */
1731 {"q:/a", URL_FILE_USE_PATHURL
, "file://q:\\a"},
1732 {"q:/a/../..", URL_FILE_USE_PATHURL
, "file://q:\\..\\"},
1733 {"q:a/../../b/..", URL_FILE_USE_PATHURL
, "file://q:a\\..\\..\\"},
1734 {"q:./../../b/..", URL_FILE_USE_PATHURL
, "file://q:.\\..\\..\\"},
1735 {"q:/a", URL_WININET_COMPATIBILITY
, "file://q:\\a"},
1736 {"q:/a/../..", URL_WININET_COMPATIBILITY
, "file://q:\\..\\"},
1737 {"q:a/../../b/..", URL_WININET_COMPATIBILITY
, "file://q:a\\..\\..\\"},
1738 {"q:./../../b/..", URL_WININET_COMPATIBILITY
, "file://q:.\\..\\..\\"},
1740 {"q:/a/b?c/../d", 0, "file:///q:/a/d"},
1741 {"q:/a/b#c/../d", 0, "file:///q:/a/d"},
1742 {"q:a?b", URL_FILE_USE_PATHURL
, "file://q:a"},
1744 {"q:a\\b\\", 0, "file:///q:a/b/"},
1745 {"q:\\a/b", 0, "file:///q:/a/b"},
1747 /* Drive paths are also unique in that unsafe characters (and spaces)
1748 * are automatically escaped—but not if the file flags are used. */
1750 {"q:/a/b !\"$%&'()*+,-:;<=>@[]^_`{|}~c", 0, "file:///q:/a/b%20!%22$%25%26'()*+,-:;%3C=%3E@%5B%5D%5E_%60%7B%7C%7D~c"},
1751 {"q:/a/b &c", URL_FILE_USE_PATHURL
, "file://q:\\a\\b &c"},
1752 {"q:/a/b &c", URL_WININET_COMPATIBILITY
, "file://q:\\a\\b &c"},
1754 {"q:/a/b%20%26c", 0, "file:///q:/a/b%2520%2526c"},
1755 {"q:/a/b%20%26c", URL_UNESCAPE
, "file:///q:/a/b &c"},
1756 {"q:/a/b%20%26c", URL_UNESCAPE
| URL_ESCAPE_UNSAFE
, "file:///q:/a/b%20%26c"},
1757 {"q:/a/b%20%26c", URL_FILE_USE_PATHURL
, "file://q:\\a\\b &c"},
1758 {"q:/a/b%20%26c", URL_FILE_USE_PATHURL
| URL_UNESCAPE
, "file://q:\\a\\b &c"},
1759 {"q:/a/b%20%26c", URL_WININET_COMPATIBILITY
, "file://q:\\a\\b%20%26c"},
1760 {"q:/a/b%20%26c", URL_WININET_COMPATIBILITY
| URL_UNESCAPE
, "file://q:\\a\\b &c"},
1762 {"q|a", 0, "file:///q%7Ca"},
1764 {"Q:A", 0, "file:///Q:A"},
1766 /* A double initial backslash is also converted to a file path. The same
1767 * rules for hostnames apply. */
1769 {"\\\\", 0, "file:///"},
1770 {"\\\\a", 0, "file://a/"},
1771 {"\\\\../a\\b/..\\c/.\\", 0, "file://../a/c/"},
1772 {"\\\\a/./b/../c", 0, "file://a/./b/../c"},
1773 /* And, of course, four or more slashes gets collapsed... */
1774 {"\\\\//./b/./../c", 0, "file://./c"},
1775 {"\\\\///./b/./../c", 0, "file://./c"},
1777 {"\\\\a/b?c/../d", 0, "file://a/d"},
1778 {"\\\\a/b#c/../d", 0, "file://a/d"},
1780 /* Drive paths are "recognized" too, though. The following isn't
1781 * actually a local path, but UrlCanonicalize() doesn't seem to realize
1783 {"\\\\a:/b", 0, "file:///a:/b"},
1785 {"\\\\", URL_FILE_USE_PATHURL
, "file://"},
1786 {"\\\\a", URL_FILE_USE_PATHURL
, "file://\\\\a"},
1787 {"\\\\a/./..", URL_FILE_USE_PATHURL
, "file://\\\\a\\..\\"},
1788 {"\\\\a:/b", URL_FILE_USE_PATHURL
, "file://a:\\b"},
1789 {"\\\\", URL_WININET_COMPATIBILITY
, "file://\\"},
1790 {"\\\\a", URL_WININET_COMPATIBILITY
, "file://\\\\a\\"},
1791 {"\\\\a/./..", URL_WININET_COMPATIBILITY
, "file://\\\\a\\..\\"},
1792 {"\\\\a:/b", URL_WININET_COMPATIBILITY
, "file://a:\\b"},
1794 /* And, as with drive paths, unsafe characters are escaped. */
1795 {"\\\\a/b !\"$%&'()*+,-:;<=>@[]^_`{|}~c", 0, "file://a/b%20!%22$%25%26'()*+,-:;%3C=%3E@%5B%5D%5E_%60%7B%7C%7D~c"},
1796 {"\\\\a/b &c", URL_FILE_USE_PATHURL
, "file://\\\\a\\b &c"},
1797 {"\\\\a/b &c", URL_WININET_COMPATIBILITY
, "file://\\\\a\\b &c"},
1799 {"\\\\/b", 0, "file:///b"},
1800 {"\\\\/b", URL_FILE_USE_PATHURL
, "file://\\b"},
1801 {"\\\\localhost/b", URL_FILE_USE_PATHURL
, "file://\\b"},
1802 {"\\\\127.0.0.1/b", URL_FILE_USE_PATHURL
, "file://\\\\127.0.0.1\\b"},
1803 {"\\\\localhost/b", URL_WININET_COMPATIBILITY
, "file://\\b"},
1804 {"\\\\127.0.0.1/b", URL_WININET_COMPATIBILITY
, "file://\\\\127.0.0.1\\b"},
1806 {"\\\\A/B", 0, "file://A/B"},
1808 {"file:///c:/tests/foo%20bar", URL_UNESCAPE
, "file:///c:/tests/foo bar"},
1809 {"file:///c:/tests\\foo%20bar", URL_UNESCAPE
, "file:///c:/tests/foo bar"},
1810 {"file:///c:/tests/foo%20bar", 0, "file:///c:/tests/foo%20bar"},
1811 {"file:///c:/tests/foo%20bar", URL_FILE_USE_PATHURL
, "file://c:\\tests\\foo bar"},
1812 {"file://localhost/c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL
, "file://c:\\tests\\foo bar"},
1813 {"file://localhost\\c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL
, "file://c:\\tests\\foo bar"},
1814 {"file://localhost\\\\c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL
, "file://c:\\tests\\foo bar"},
1815 {"file://localhost\\c:\\tests/../tests/foo%20bar", URL_FILE_USE_PATHURL
, "file://c:\\tests\\foo bar"},
1816 {"file://c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL
, "file://c:\\tests\\foo bar"},
1817 {"file://c:/tests\\../tests/foo%20bar", URL_FILE_USE_PATHURL
, "file://c:\\tests\\foo bar"},
1818 {"file://c:/tests/foo%20bar", URL_FILE_USE_PATHURL
, "file://c:\\tests\\foo bar"},
1819 {"file:///c://tests/foo%20bar", URL_FILE_USE_PATHURL
, "file://c:\\\\tests\\foo bar"},
1820 {"file:///c:\\tests\\foo bar", 0, "file:///c:/tests/foo bar"},
1821 {"file:///c:\\tests\\foo bar", URL_DONT_SIMPLIFY
, "file:///c:/tests/foo bar"},
1822 {"file:///c:\\tests\\foobar", 0, "file:///c:/tests/foobar"},
1823 {"file:///c:\\tests\\foobar", URL_WININET_COMPATIBILITY
, "file://c:\\tests\\foobar"},
1824 {"file://home/user/file", 0, "file://home/user/file"},
1825 {"file:///home/user/file", 0, "file:///home/user/file"},
1826 {"file:////home/user/file", 0, "file://home/user/file"},
1827 {"file://home/user/file", URL_WININET_COMPATIBILITY
, "file://\\\\home\\user\\file"},
1828 {"file:///home/user/file", URL_WININET_COMPATIBILITY
, "file://\\home\\user\\file"},
1829 {"file:////home/user/file", URL_WININET_COMPATIBILITY
, "file://\\\\home\\user\\file"},
1830 {"file://///home/user/file", URL_WININET_COMPATIBILITY
, "file://\\\\home\\user\\file"},
1831 {"file://C:/user/file", 0, "file:///C:/user/file"},
1832 {"file://C:/user/file/../asdf", 0, "file:///C:/user/asdf"},
1833 {"file:///C:/user/file", 0, "file:///C:/user/file"},
1834 {"file:////C:/user/file", 0, "file:///C:/user/file"},
1835 {"file://C:/user/file", URL_WININET_COMPATIBILITY
, "file://C:\\user\\file"},
1836 {"file:///C:/user/file", URL_WININET_COMPATIBILITY
, "file://C:\\user\\file"},
1837 {"file:////C:/user/file", URL_WININET_COMPATIBILITY
, "file://C:\\user\\file"},
1840 static const struct canonicalize_test misc_tests
[] =
1844 /* If both slashes are omitted, everything afterwards is replicated
1845 * as-is, with the exception that the final period is dropped from
1848 {"wine:.", 0, "wine:"},
1849 {"wine:.", URL_DONT_SIMPLIFY
, "wine:."},
1850 {"wine:./", 0, "wine:./"},
1851 {"wine:..", 0, "wine:.."},
1852 {"wine:../", 0, "wine:../"},
1853 {"wine:a", 0, "wine:a"},
1854 {"wine:a/", 0, "wine:a/"},
1855 {"wine:a/b/./../c", 0, "wine:a/b/./../c"},
1857 {"wine:a/b?c/./d", 0, "wine:a/b?c/./d"},
1858 {"wine:a/b#c/./d", 0, "wine:a/b#c/./d"},
1859 {"wine:a/b#c?d", 0, "wine:a/b?d#c"},
1860 {"wine:.#c?d", 0, "wine:?d#c"},
1862 /* A backslash directly after the colon is not treated specially. */
1863 {"wine:\\././a", 0, "wine:\\././a"},
1865 {"wine:a/b &c", 0, "wine:a/b &c"},
1867 /* If there's no scheme or hostname, things mostly follow the "unknown
1868 * scheme" rules, except that a would-be empty string results in a
1869 * single slash instead. */
1874 {".", URL_DONT_SIMPLIFY
, "./"},
1880 {"a/./b", 0, "a/b"},
1884 {"../a", 0, "../a"},
1885 {"../a/..", 0, "../"},
1887 {"a/../..", 0, "../"},
1888 {"a/b/..", 0, "a/"},
1889 {"a/b/../", 0, "a/"},
1890 {"a/b/../c", 0, "a/c"},
1891 {"a/b/../c/..", 0, "a/"},
1892 {"a/b/../c/../..", 0, "/"},
1894 {"a/b?c/./d", 0, "a/b?c/./d"},
1895 {"a/b#c/./d", 0, "a/b#c/./d"},
1896 {"a/b#c?d", 0, "a/b?d#c"},
1900 {"?c/./d", 0, "?c/./d"},
1901 {"#c/./d", 0, "#c/./d"},
1903 {"a\\b/..", 0, "/"},
1905 {"a/b &c", 0, "a/b &c"},
1907 /* A colon by itself is not interpreted as any sort of scheme. */
1908 {"://../../a", 0, "a"},
1910 /* mk: is another idiosyncratic scheme, although thankfully it behaves
1911 * rather simply. It has no concept of a hostname; if two slashes follow
1912 * the scheme it simply treats them as two empty path elements. */
1915 {"mk:..", 0, "mk:"},
1916 {"mk:/", 0, "mk:/"},
1917 {"mk:/.", 0, "mk:/"},
1918 {"mk:/..", 0, "mk:"},
1919 {"mk:a", 0, "mk:a"},
1920 {"mk:a:", 0, "mk:a:"},
1921 {"mk://", 0, "mk://"},
1922 {"mk://.", 0, "mk://"},
1923 {"mk://..", 0, "mk:/"},
1924 {"mk://../..", 0, "mk:"},
1925 {"mk://../..", URL_DONT_SIMPLIFY
, "mk://../.."},
1926 {"mk://../../..", 0, "mk:"},
1928 /* Backslashes are not translated into forward slashes. They are treated
1929 * as path separators, but in a somewhat buggy manner: only dots before
1930 * a forward slash are collapsed, and a double dot rewinds to the
1931 * previous forward slash. */
1932 {"mk:a/.\\", 0, "mk:a/.\\"},
1933 {"mk:a/.\\b", 0, "mk:a/.\\b"},
1934 {"mk:a\\.\\b", 0, "mk:a\\.\\b"},
1935 {"mk:a\\./b", 0, "mk:a\\b"},
1936 {"mk:a./b", 0, "mk:a./b"},
1937 {"mk:a\\b/..\\c", 0, "mk:a\\b/..\\c"},
1938 {"mk:a\\b\\..\\c", 0, "mk:a\\b\\..\\c"},
1939 {"mk:a/b\\../c", 0, "mk:a/c"},
1940 {"mk:a\\b../c", 0, "mk:a\\b../c"},
1942 /* Progids get a forward slash appended if there isn't one already, and
1943 * dots don't rewind past them. Despite the fact that progids are
1944 * supposed to end with a colon, UrlCanonicalize() considers them to
1945 * end with the slash.
1947 * If the first path segment is a dot or double dot, it's treated as
1948 * a relative path, like http, but only before a forward slash. */
1950 {"mk:@", 0, "mk:@/"},
1951 {"mk:@progid", 0, "mk:@progid/"},
1952 {"mk:@progid:a", 0, "mk:@progid:a/"},
1953 {"mk:@progid:a/b", 0, "mk:@progid:a/b"},
1954 {"mk:@Progid:a/b/../..", 0, "mk:@Progid:a/"},
1955 {"mk:@progid/a", 0, "mk:@progid/a"},
1956 {"mk:@progid\\a", 0, "mk:@progid\\a/"},
1957 {"mk:@progid/a/../..", 0, "mk:@progid/"},
1958 {"mk:@progid/.", 0, "mk:@progid/."},
1959 {"mk:@progid/.?", 0, "mk:@progid/.?"},
1960 {"mk:@progid/./..", 0, "mk:@progid/./.."},
1961 {"mk:@progid/../..", 0, "mk:@progid/../.."},
1962 {"mk:@progid/a\\.\\b", 0, "mk:@progid/a\\.\\b"},
1963 {"mk:@progid/a\\..\\b", 0, "mk:@progid/a\\..\\b"},
1964 {"mk:@progid/.\\..", 0, "mk:@progid/"},
1966 {"mk:a/b?c/../d", 0, "mk:a/b?c/../d"},
1967 {"mk:a/b#c/../d", 0, "mk:a/b#c/../d"},
1968 {"mk:a/b#c?d", 0, "mk:a/b#c?d"},
1969 {"mk:@progid/a/b?c/../d", 0, "mk:@progid/a/b?c/../d"},
1970 {"mk:@progid?c/d/..", 0, "mk:@progid?c/"},
1972 {"mk:a/b &c", 0, "mk:a/b &c"},
1974 {"mk:@MSITStore:dir/test.chm::/file.html/..", 0, "mk:@MSITStore:dir/test.chm::/"},
1975 {"mk:@MSITStore:dir/test.chm::/file.html/../..", 0, "mk:@MSITStore:dir/"},
1977 /* Whitespace except for plain spaces are stripped before parsing. */
1978 {" \t\n\rwi\t\n\rne\t\n\r:\t\n\r/\t\n\r/\t\n\r./../a/.\t\n\r./ \t\n\r", 0, "wine://./../"},
1979 /* Initial and final spaces and C0 control characters are also stripped,
1980 * but not 007F or C1 control characters. */
1981 {" \a\t\x01 wine://./.. \x1f\n\v ", 0, "wine://./../"},
1982 {" wine ://./..", 0, "wine :/"},
1983 {" wine: //a/../b", 0, "wine: //a/../b"},
1984 {" wine://a/b c/.. ", 0, "wine://a/"},
1985 {"\x7f/\a/\v/\x01/\x1f/\x80", 0, "\x7f/\a/\v/\x01/\x1f/\x80"},
1987 /* Schemes are not case-sensitive, but are flattened to lowercase.
1988 * The hostname for http-like schemes is also flattened to lowercase
1989 * (but not for file; see above). */
1990 {"wInE://A/B", 0, "wine://A/B"},
1991 {"hTtP://A/b/../../C", 0, "http://a/C"},
1992 {"fTP://A/B\\./C", 0, "ftp://a/B\\C"},
1993 {"aBoUT://A/B/./", 0, "about://A/B/./"},
1994 {"mK://..", 0, "mk:/"},
1996 /* Characters allowed in a scheme are alphanumeric, hyphen, plus, period. */
1997 {"0Aa+-.://./..", 0, "0aa+-.://./../"},
1998 {"a_://./..", 0, "a_:/"},
1999 {"a,://./..", 0, "a,:/"},
2001 {"/uri-res/N2R?urn:sha1:B3K", URL_DONT_ESCAPE_EXTRA_INFO
| URL_WININET_COMPATIBILITY
, "/uri-res/N2R?urn:sha1:B3K"} /* LimeWire online installer calls this */,
2002 {"mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm", 0,
2003 "mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm"},
2006 static const DWORD file_flags
[] = {0, URL_FILE_USE_PATHURL
, URL_WININET_COMPATIBILITY
};
2008 urllen
= lstrlenA(winehqA
);
2010 /* Parameter checks */
2011 dwSize
= ARRAY_SIZE(szReturnUrl
);
2012 hr
= UrlCanonicalizeA(NULL
, szReturnUrl
, &dwSize
, URL_UNESCAPE
);
2013 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#lx.\n", hr
);
2014 ok(dwSize
== ARRAY_SIZE(szReturnUrl
), "got size %lu\n", dwSize
);
2016 dwSize
= ARRAY_SIZE(szReturnUrl
);
2017 hr
= UrlCanonicalizeA(winehqA
, NULL
, &dwSize
, URL_UNESCAPE
);
2018 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#lx.\n", hr
);
2019 ok(dwSize
== ARRAY_SIZE(szReturnUrl
), "got size %lu\n", dwSize
);
2021 hr
= UrlCanonicalizeA(winehqA
, szReturnUrl
, NULL
, URL_UNESCAPE
);
2022 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#lx.\n", hr
);
2025 hr
= UrlCanonicalizeA(winehqA
, szReturnUrl
, &dwSize
, URL_UNESCAPE
);
2026 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#lx.\n", hr
);
2027 ok(!dwSize
, "got size %lu\n", dwSize
);
2029 /* buffer has no space for the result */
2031 memset(szReturnUrl
, '#', urllen
+4);
2032 szReturnUrl
[urllen
+4] = '\0';
2033 SetLastError(0xdeadbeef);
2034 hr
= UrlCanonicalizeA(winehqA
, szReturnUrl
, &dwSize
, URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
);
2035 ok( (hr
== E_POINTER
) && (dwSize
== (urllen
+ 1)),
2036 "got 0x%lx with %lu and size %lu for '%s' and %u (expected 'E_POINTER' and size %lu)\n",
2037 hr
, GetLastError(), dwSize
, szReturnUrl
, lstrlenA(szReturnUrl
), urllen
+1);
2039 /* buffer has no space for the terminating '\0' */
2041 memset(szReturnUrl
, '#', urllen
+4);
2042 szReturnUrl
[urllen
+4] = '\0';
2043 SetLastError(0xdeadbeef);
2044 hr
= UrlCanonicalizeA(winehqA
, szReturnUrl
, &dwSize
, URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
);
2045 ok( (hr
== E_POINTER
) && (dwSize
== (urllen
+ 1)),
2046 "got 0x%lx with %lu and size %lu for '%s' and %u (expected 'E_POINTER' and size %lu)\n",
2047 hr
, GetLastError(), dwSize
, szReturnUrl
, lstrlenA(szReturnUrl
), urllen
+1);
2049 /* buffer has the required size */
2051 memset(szReturnUrl
, '#', urllen
+4);
2052 szReturnUrl
[urllen
+4] = '\0';
2053 SetLastError(0xdeadbeef);
2054 hr
= UrlCanonicalizeA(winehqA
, szReturnUrl
, &dwSize
, URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
);
2055 ok( (hr
== S_OK
) && (dwSize
== urllen
),
2056 "got 0x%lx with %lu and size %lu for '%s' and %u (expected 'S_OK' and size %lu)\n",
2057 hr
, GetLastError(), dwSize
, szReturnUrl
, lstrlenA(szReturnUrl
), urllen
);
2059 /* buffer is larger as the required size */
2061 memset(szReturnUrl
, '#', urllen
+4);
2062 szReturnUrl
[urllen
+4] = '\0';
2063 SetLastError(0xdeadbeef);
2064 hr
= UrlCanonicalizeA(winehqA
, szReturnUrl
, &dwSize
, URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
);
2065 ok( (hr
== S_OK
) && (dwSize
== urllen
),
2066 "got 0x%lx with %lu and size %lu for '%s' and %u (expected 'S_OK' and size %lu)\n",
2067 hr
, GetLastError(), dwSize
, szReturnUrl
, lstrlenA(szReturnUrl
), urllen
);
2069 /* length is set to 0 */
2071 memset(szReturnUrl
, '#', urllen
+4);
2072 szReturnUrl
[urllen
+4] = '\0';
2073 SetLastError(0xdeadbeef);
2074 hr
= UrlCanonicalizeA(winehqA
, szReturnUrl
, &dwSize
, URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
);
2075 ok( (hr
== E_INVALIDARG
) && (dwSize
== 0),
2076 "got 0x%lx with %lu and size %lu for '%s' and %u (expected 'E_INVALIDARG' and size %u)\n",
2077 hr
, GetLastError(), dwSize
, szReturnUrl
, lstrlenA(szReturnUrl
), 0);
2079 /* url length > INTERNET_MAX_URL_SIZE */
2080 dwSize
=sizeof(szReturnUrl
);
2081 memset(longurl
, 'a', sizeof(longurl
));
2082 memcpy(longurl
, winehqA
, sizeof(winehqA
)-1);
2083 longurl
[sizeof(longurl
)-1] = '\0';
2084 hr
= UrlCanonicalizeA(longurl
, szReturnUrl
, &dwSize
, URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
);
2085 ok(hr
== S_OK
, "hr = %lx\n", hr
);
2086 ok(dwSize
== strlen(szReturnUrl
), "got size %lu\n", dwSize
);
2088 for (f
= 0; f
< ARRAY_SIZE(file_flags
); ++f
)
2090 for (i
= 0; i
< ARRAY_SIZE(unk_scheme_tests
); ++i
)
2092 check_url_canonicalize(unk_scheme_tests
[i
].url
,
2093 unk_scheme_tests
[i
].flags
| file_flags
[f
], unk_scheme_tests
[i
].expect
);
2094 sprintf(url
, "wine:%s", unk_scheme_tests
[i
].url
);
2095 sprintf(expect
, "wine:%s", unk_scheme_tests
[i
].expect
);
2096 check_url_canonicalize(url
, unk_scheme_tests
[i
].flags
| file_flags
[f
], expect
);
2099 for (i
= 0; i
< ARRAY_SIZE(http_tests
); ++i
)
2121 for (j
= 0; j
< ARRAY_SIZE(prefixes
); ++j
)
2123 sprintf(url
, "%s:%s", prefixes
[j
].prefix
, http_tests
[i
].url
);
2124 if (prefixes
[j
].ftp_like
&& http_tests
[i
].expect_ftp
)
2125 sprintf(expect
, "%s:%s", prefixes
[j
].prefix
, http_tests
[i
].expect_ftp
);
2127 sprintf(expect
, "%s:%s", prefixes
[j
].prefix
, http_tests
[i
].expect
);
2129 check_url_canonicalize(url
, http_tests
[i
].flags
| file_flags
[f
], expect
);
2133 for (i
= 0; i
< ARRAY_SIZE(opaque_tests
); ++i
)
2135 static const char *const prefixes
[] = {"about", "javascript", "mailto", "shell", "vbscript"};
2137 for (j
= 0; j
< ARRAY_SIZE(prefixes
); ++j
)
2139 sprintf(url
, "%s:%s", prefixes
[j
], opaque_tests
[i
].url
);
2140 sprintf(expect
, "%s:%s", prefixes
[j
], opaque_tests
[i
].expect
);
2141 check_url_canonicalize(url
, opaque_tests
[i
].flags
| file_flags
[f
], expect
);
2145 for (i
= 0; i
< ARRAY_SIZE(misc_tests
); i
++)
2146 check_url_canonicalize(misc_tests
[i
].url
, misc_tests
[i
].flags
| file_flags
[f
], misc_tests
[i
].expect
);
2149 for (i
= 0; i
< ARRAY_SIZE(file_tests
); i
++)
2150 check_url_canonicalize(file_tests
[i
].url
, file_tests
[i
].flags
, file_tests
[i
].expect
);
2153 /* ########################### */
2155 static void test_UrlCanonicalizeW(void)
2157 WCHAR szReturnUrl
[INTERNET_MAX_URL_LENGTH
];
2163 urllen
= lstrlenW(winehqW
);
2165 /* Parameter checks */
2166 dwSize
= ARRAY_SIZE(szReturnUrl
);
2167 hr
= UrlCanonicalizeW(NULL
, szReturnUrl
, &dwSize
, URL_UNESCAPE
);
2168 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#lx.\n", hr
);
2169 ok(dwSize
== ARRAY_SIZE(szReturnUrl
), "got size %lu\n", dwSize
);
2171 dwSize
= ARRAY_SIZE(szReturnUrl
);
2172 hr
= UrlCanonicalizeW(winehqW
, NULL
, &dwSize
, URL_UNESCAPE
);
2173 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#lx.\n", hr
);
2174 ok(dwSize
== ARRAY_SIZE(szReturnUrl
), "got size %lu\n", dwSize
);
2176 hr
= UrlCanonicalizeW(winehqW
, szReturnUrl
, NULL
, URL_UNESCAPE
);
2177 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#lx.\n", hr
);
2180 hr
= UrlCanonicalizeW(winehqW
, szReturnUrl
, &dwSize
, URL_UNESCAPE
);
2181 ok(hr
== E_INVALIDARG
, "Got unexpected hr %#lx.\n", hr
);
2182 ok(!dwSize
, "got size %lu\n", dwSize
);
2184 /* buffer has no space for the result */
2185 dwSize
= (urllen
-1);
2186 memset(szReturnUrl
, '#', (urllen
+4) * sizeof(WCHAR
));
2187 szReturnUrl
[urllen
+4] = '\0';
2188 SetLastError(0xdeadbeef);
2189 hr
= UrlCanonicalizeW(winehqW
, szReturnUrl
, &dwSize
, URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
);
2190 ok( (hr
== E_POINTER
) && (dwSize
== (urllen
+ 1)),
2191 "got 0x%lx with %lu and size %lu for %u (expected 'E_POINTER' and size %lu)\n",
2192 hr
, GetLastError(), dwSize
, lstrlenW(szReturnUrl
), urllen
+1);
2195 /* buffer has no space for the terminating '\0' */
2197 memset(szReturnUrl
, '#', (urllen
+4) * sizeof(WCHAR
));
2198 szReturnUrl
[urllen
+4] = '\0';
2199 SetLastError(0xdeadbeef);
2200 hr
= UrlCanonicalizeW(winehqW
, szReturnUrl
, &dwSize
, URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
);
2201 ok( (hr
== E_POINTER
) && (dwSize
== (urllen
+ 1)),
2202 "got 0x%lx with %lu and size %lu for %u (expected 'E_POINTER' and size %lu)\n",
2203 hr
, GetLastError(), dwSize
, lstrlenW(szReturnUrl
), urllen
+1);
2205 /* buffer has the required size */
2207 memset(szReturnUrl
, '#', (urllen
+4) * sizeof(WCHAR
));
2208 szReturnUrl
[urllen
+4] = '\0';
2209 SetLastError(0xdeadbeef);
2210 hr
= UrlCanonicalizeW(winehqW
, szReturnUrl
, &dwSize
, URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
);
2211 ok( (hr
== S_OK
) && (dwSize
== urllen
),
2212 "got 0x%lx with %lu and size %lu for %u (expected 'S_OK' and size %lu)\n",
2213 hr
, GetLastError(), dwSize
, lstrlenW(szReturnUrl
), urllen
);
2215 /* buffer is larger as the required size */
2216 dwSize
= (urllen
+2);
2217 memset(szReturnUrl
, '#', (urllen
+4) * sizeof(WCHAR
));
2218 szReturnUrl
[urllen
+4] = '\0';
2219 SetLastError(0xdeadbeef);
2220 hr
= UrlCanonicalizeW(winehqW
, szReturnUrl
, &dwSize
, URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
);
2221 ok( (hr
== S_OK
) && (dwSize
== urllen
),
2222 "got 0x%lx with %lu and size %lu for %u (expected 'S_OK' and size %lu)\n",
2223 hr
, GetLastError(), dwSize
, lstrlenW(szReturnUrl
), urllen
);
2225 /* Only ASCII alphanumeric characters are allowed in a scheme. */
2226 dwSize
= ARRAY_SIZE(szReturnUrl
);
2227 hr
= UrlCanonicalizeW(L
"f\xe8ve://./..", szReturnUrl
, &dwSize
, 0);
2228 ok(hr
== S_OK
, "Got hr %#lx.\n", hr
);
2229 ok(!wcscmp(szReturnUrl
, L
"f\xe8ve:/"), "Got URL %s.\n", debugstr_w(szReturnUrl
));
2230 ok(dwSize
== wcslen(szReturnUrl
), "got size %lu\n", dwSize
);
2232 /* check that the characters 1..32 are chopped from the end of the string */
2233 for (i
= 1; i
< 65536; i
++)
2239 wcscpy(szUrl
, L
"http://www.winehq.org/X");
2240 pos
= lstrlenW(szUrl
) - 1;
2242 urllen
= INTERNET_MAX_URL_LENGTH
;
2243 UrlCanonicalizeW(szUrl
, szReturnUrl
, &urllen
, 0);
2244 choped
= lstrlenW(szReturnUrl
) < lstrlenW(szUrl
);
2245 ok(choped
== (i
<= 32), "Incorrect char chopping for char %d\n", i
);
2249 /* ########################### */
2251 static void check_url_combine(const char *szUrl1
, const char *szUrl2
, DWORD dwFlags
, const char *szExpectUrl
)
2254 CHAR szReturnUrl
[INTERNET_MAX_URL_LENGTH
];
2255 WCHAR wszReturnUrl
[INTERNET_MAX_URL_LENGTH
];
2256 LPWSTR wszUrl1
, wszUrl2
, wszExpectUrl
, wszConvertedUrl
;
2259 DWORD dwExpectLen
= lstrlenA(szExpectUrl
);
2261 wszUrl1
= GetWideString(szUrl1
);
2262 wszUrl2
= GetWideString(szUrl2
);
2263 wszExpectUrl
= GetWideString(szExpectUrl
);
2265 dwSize
= ARRAY_SIZE(szReturnUrl
);
2266 hr
= UrlCombineA(szUrl1
, szUrl2
, szReturnUrl
, &dwSize
, dwFlags
);
2267 ok(hr
== S_OK
, "Got unexpected hr %#lx.\n", hr
);
2268 ok(dwSize
== dwExpectLen
, "Got length %ld, expected %ld\n", dwSize
, dwExpectLen
);
2269 ok(!strcmp(szReturnUrl
, szExpectUrl
), "Expected %s, got %s.\n", szExpectUrl
, szReturnUrl
);
2271 dwSize
= ARRAY_SIZE(wszReturnUrl
);
2272 hr
= UrlCombineW(wszUrl1
, wszUrl2
, wszReturnUrl
, &dwSize
, dwFlags
);
2273 ok(hr
== S_OK
, "Got unexpected hr %#lx.\n", hr
);
2274 ok(dwSize
== dwExpectLen
, "Got length %ld, expected %ld\n", dwSize
, dwExpectLen
);
2275 wszConvertedUrl
= GetWideString(szReturnUrl
);
2276 ok(!wcscmp(wszReturnUrl
, wszConvertedUrl
), "Expected %s, got %s.\n",
2277 debugstr_w(wszConvertedUrl
), debugstr_w(wszReturnUrl
));
2278 FreeWideString(wszConvertedUrl
);
2280 FreeWideString(wszUrl1
);
2281 FreeWideString(wszUrl2
);
2282 FreeWideString(wszExpectUrl
);
2285 /* ########################### */
2287 static void test_UrlCombine(void)
2295 hr
= UrlCombineA("http://base/", "relative", NULL
, NULL
, 0);
2296 ok(hr
== E_INVALIDARG
, "Got hr %#lx.\n", hr
);
2299 hr
= UrlCombineA("http://base/", "relative", NULL
, &size
, 0);
2300 ok(hr
== E_POINTER
, "Got hr %#lx.\n", hr
);
2301 ok(size
== strlen("http://base/relative") + 1, "Got size %lu.\n", size
);
2304 strcpy(buffer
, "x");
2305 hr
= UrlCombineA("http://base/", "relative", buffer
, &size
, 0);
2306 ok(hr
== E_POINTER
, "Got hr %#lx.\n", hr
);
2307 ok(size
== strlen("http://base/relative") + 1, "Got size %lu.\n", size
);
2308 ok(!strcmp(buffer
, "x"), "Got buffer contents %s.\n", debugstr_a(buffer
));
2310 strcpy(buffer
, "x");
2311 hr
= UrlCombineA("http://base/", "relative", buffer
, &size
, 0);
2312 ok(hr
== S_OK
, "Got hr %#lx.\n", hr
);
2313 ok(size
== strlen("http://base/relative"), "Got size %lu.\n", size
);
2314 ok(!strcmp(buffer
, "http://base/relative"), "Got buffer contents %s.\n", debugstr_a(buffer
));
2316 hr
= UrlCombineW(L
"http://base/", L
"relative", NULL
, NULL
, 0);
2317 ok(hr
== E_INVALIDARG
, "Got hr %#lx.\n", hr
);
2320 hr
= UrlCombineW(L
"http://base/", L
"relative", NULL
, &size
, 0);
2321 ok(hr
== E_POINTER
, "Got hr %#lx.\n", hr
);
2322 ok(size
== strlen("http://base/relative") + 1, "Got size %lu.\n", size
);
2325 wcscpy(bufferW
, L
"x");
2326 hr
= UrlCombineW(L
"http://base/", L
"relative", bufferW
, &size
, 0);
2327 ok(hr
== E_POINTER
, "Got hr %#lx.\n", hr
);
2328 ok(size
== strlen("http://base/relative") + 1, "Got size %lu.\n", size
);
2329 ok(!wcscmp(bufferW
, L
"x"), "Got buffer contents %s.\n", debugstr_a(buffer
));
2331 wcscpy(bufferW
, L
"x");
2332 hr
= UrlCombineW(L
"http://base/", L
"relative", bufferW
, &size
, 0);
2333 ok(hr
== S_OK
, "Got hr %#lx.\n", hr
);
2334 ok(size
== strlen("http://base/relative"), "Got size %lu.\n", size
);
2335 ok(!wcscmp(bufferW
, L
"http://base/relative"), "Got buffer contents %s.\n", debugstr_w(bufferW
));
2337 for (i
= 0; i
< ARRAY_SIZE(TEST_COMBINE
); i
++) {
2338 check_url_combine(TEST_COMBINE
[i
].url1
, TEST_COMBINE
[i
].url2
, TEST_COMBINE
[i
].flags
, TEST_COMBINE
[i
].expecturl
);
2342 /* ########################### */
2344 static void test_UrlCreateFromPath(void)
2347 char ret_url
[INTERNET_MAX_URL_LENGTH
];
2349 WCHAR ret_urlW
[INTERNET_MAX_URL_LENGTH
];
2350 WCHAR
*pathW
, *urlW
;
2352 for (i
= 0; i
< ARRAY_SIZE(TEST_URLFROMPATH
); i
++) {
2353 len
= INTERNET_MAX_URL_LENGTH
;
2354 ret
= UrlCreateFromPathA(TEST_URLFROMPATH
[i
].path
, ret_url
, &len
, 0);
2355 ok(ret
== TEST_URLFROMPATH
[i
].ret
, "ret %08lx from path %s\n", ret
, TEST_URLFROMPATH
[i
].path
);
2356 ok(!lstrcmpiA(ret_url
, TEST_URLFROMPATH
[i
].url
), "url %s from path %s\n", ret_url
, TEST_URLFROMPATH
[i
].path
);
2357 ok(len
== strlen(ret_url
), "ret len %ld from path %s\n", len
, TEST_URLFROMPATH
[i
].path
);
2359 len
= INTERNET_MAX_URL_LENGTH
;
2360 pathW
= GetWideString(TEST_URLFROMPATH
[i
].path
);
2361 urlW
= GetWideString(TEST_URLFROMPATH
[i
].url
);
2362 ret
= UrlCreateFromPathW(pathW
, ret_urlW
, &len
, 0);
2363 WideCharToMultiByte(CP_ACP
, 0, ret_urlW
, -1, ret_url
, sizeof(ret_url
),0,0);
2364 ok(ret
== TEST_URLFROMPATH
[i
].ret
, "ret %08lx from path L\"%s\", expected %08lx\n",
2365 ret
, TEST_URLFROMPATH
[i
].path
, TEST_URLFROMPATH
[i
].ret
);
2366 ok(!lstrcmpiW(ret_urlW
, urlW
), "got %s expected %s from path L\"%s\"\n",
2367 ret_url
, TEST_URLFROMPATH
[i
].url
, TEST_URLFROMPATH
[i
].path
);
2368 ok(len
== lstrlenW(ret_urlW
), "ret len %ld from path L\"%s\"\n", len
, TEST_URLFROMPATH
[i
].path
);
2369 FreeWideString(urlW
);
2370 FreeWideString(pathW
);
2374 /* ########################### */
2376 static void test_UrlIs_null(DWORD flag
)
2379 ret
= UrlIsA(NULL
, flag
);
2380 ok(ret
== FALSE
, "pUrlIsA(NULL, %ld) failed\n", flag
);
2381 ret
= UrlIsW(NULL
, flag
);
2382 ok(ret
== FALSE
, "pUrlIsW(NULL, %ld) failed\n", flag
);
2385 static void test_UrlIs(void)
2391 test_UrlIs_null(URLIS_APPLIABLE
);
2392 test_UrlIs_null(URLIS_DIRECTORY
);
2393 test_UrlIs_null(URLIS_FILEURL
);
2394 test_UrlIs_null(URLIS_HASQUERY
);
2395 test_UrlIs_null(URLIS_NOHISTORY
);
2396 test_UrlIs_null(URLIS_OPAQUE
);
2397 test_UrlIs_null(URLIS_URL
);
2399 for (i
= 0; i
< ARRAY_SIZE(TEST_PATH_IS_URL
); i
++) {
2400 MultiByteToWideChar(CP_ACP
, 0, TEST_PATH_IS_URL
[i
].path
, -1, wurl
, ARRAY_SIZE(wurl
));
2402 ret
= UrlIsA( TEST_PATH_IS_URL
[i
].path
, URLIS_URL
);
2403 ok( ret
== TEST_PATH_IS_URL
[i
].expect
,
2404 "returned %d from path %s, expected %d\n", ret
, TEST_PATH_IS_URL
[i
].path
,
2405 TEST_PATH_IS_URL
[i
].expect
);
2407 ret
= UrlIsW( wurl
, URLIS_URL
);
2408 ok( ret
== TEST_PATH_IS_URL
[i
].expect
,
2409 "returned %d from path (UrlIsW) %s, expected %d\n", ret
,
2410 TEST_PATH_IS_URL
[i
].path
, TEST_PATH_IS_URL
[i
].expect
);
2412 for (i
= 0; i
< ARRAY_SIZE(TEST_URLIS_ATTRIBS
); i
++) {
2413 MultiByteToWideChar(CP_ACP
, 0, TEST_URLIS_ATTRIBS
[i
].url
, -1, wurl
, ARRAY_SIZE(wurl
));
2415 ret
= UrlIsA( TEST_URLIS_ATTRIBS
[i
].url
, URLIS_OPAQUE
);
2416 ok( ret
== TEST_URLIS_ATTRIBS
[i
].expectOpaque
,
2417 "returned %d for URLIS_OPAQUE, url \"%s\", expected %d\n", ret
, TEST_URLIS_ATTRIBS
[i
].url
,
2418 TEST_URLIS_ATTRIBS
[i
].expectOpaque
);
2419 ret
= UrlIsA( TEST_URLIS_ATTRIBS
[i
].url
, URLIS_FILEURL
);
2420 ok( ret
== TEST_URLIS_ATTRIBS
[i
].expectFile
,
2421 "returned %d for URLIS_FILEURL, url \"%s\", expected %d\n", ret
, TEST_URLIS_ATTRIBS
[i
].url
,
2422 TEST_URLIS_ATTRIBS
[i
].expectFile
);
2424 ret
= UrlIsW( wurl
, URLIS_OPAQUE
);
2425 ok( ret
== TEST_URLIS_ATTRIBS
[i
].expectOpaque
,
2426 "returned %d for URLIS_OPAQUE (UrlIsW), url \"%s\", expected %d\n",
2427 ret
, TEST_URLIS_ATTRIBS
[i
].url
, TEST_URLIS_ATTRIBS
[i
].expectOpaque
);
2428 ret
= UrlIsW( wurl
, URLIS_FILEURL
);
2429 ok( ret
== TEST_URLIS_ATTRIBS
[i
].expectFile
,
2430 "returned %d for URLIS_FILEURL (UrlIsW), url \"%s\", expected %d\n",
2431 ret
, TEST_URLIS_ATTRIBS
[i
].url
, TEST_URLIS_ATTRIBS
[i
].expectFile
);
2435 /* ########################### */
2437 static void test_UrlUnescape(void)
2439 WCHAR urlW
[INTERNET_MAX_URL_LENGTH
], bufferW
[INTERNET_MAX_URL_LENGTH
];
2440 CHAR szReturnUrl
[INTERNET_MAX_URL_LENGTH
];
2441 DWORD dwEscaped
, unescaped
;
2442 BOOL utf8_support
= TRUE
;
2443 static char inplace
[] = "file:///C:/Program%20Files";
2444 static char another_inplace
[] = "file:///C:/Program%20Files";
2445 static const char expected
[] = "file:///C:/Program Files";
2449 for (i
= 0; i
< ARRAY_SIZE(TEST_URL_UNESCAPE
); i
++) {
2450 dwEscaped
=INTERNET_MAX_URL_LENGTH
;
2451 res
= UrlUnescapeA(TEST_URL_UNESCAPE
[i
].url
, szReturnUrl
, &dwEscaped
, 0);
2453 "UrlUnescapeA returned 0x%lx (expected S_OK) for \"%s\"\n",
2454 res
, TEST_URL_UNESCAPE
[i
].url
);
2455 ok(strcmp(szReturnUrl
,TEST_URL_UNESCAPE
[i
].expect
)==0, "Expected \"%s\", but got \"%s\" from \"%s\"\n", TEST_URL_UNESCAPE
[i
].expect
, szReturnUrl
, TEST_URL_UNESCAPE
[i
].url
);
2457 ZeroMemory(szReturnUrl
, sizeof(szReturnUrl
));
2458 /* if we set the buffer pointer to NULL here, UrlUnescape fails and the string is not converted */
2459 res
= UrlUnescapeA(TEST_URL_UNESCAPE
[i
].url
, szReturnUrl
, NULL
, 0);
2460 ok(res
== E_INVALIDARG
,
2461 "UrlUnescapeA returned 0x%lx (expected E_INVALIDARG) for \"%s\"\n",
2462 res
, TEST_URL_UNESCAPE
[i
].url
);
2463 ok(strcmp(szReturnUrl
,"")==0, "Expected empty string\n");
2466 unescaped
= INTERNET_MAX_URL_LENGTH
;
2467 lstrcpyW(urlW
, L
"%F0%9F%8D%B7");
2468 res
= UrlUnescapeW(urlW
, NULL
, &unescaped
, URL_UNESCAPE_AS_UTF8
| URL_UNESCAPE_INPLACE
);
2469 ok(res
== S_OK
, "Got %#lx.\n", res
);
2470 if (!wcscmp(urlW
, L
"\xf0\x9f\x8d\xb7"))
2472 utf8_support
= FALSE
;
2473 win_skip("Skip URL_UNESCAPE_AS_UTF8 tests for pre-win7 systems.\n");
2476 for (i
= 0; i
< ARRAYSIZE(TEST_URL_UNESCAPEW
); i
++)
2478 if (TEST_URL_UNESCAPEW
[i
].flags
& URL_UNESCAPE_AS_UTF8
&& !utf8_support
)
2481 lstrcpyW(urlW
, TEST_URL_UNESCAPEW
[i
].url
);
2483 memset(bufferW
, 0xff, sizeof(bufferW
));
2484 unescaped
= INTERNET_MAX_URL_LENGTH
;
2485 res
= UrlUnescapeW(urlW
, bufferW
, &unescaped
, TEST_URL_UNESCAPEW
[i
].flags
);
2486 ok(res
== S_OK
, "[%d]: returned %#lx.\n", i
, res
);
2487 ok(unescaped
== wcslen(TEST_URL_UNESCAPEW
[i
].expect
), "[%d]: got unescaped %ld.\n", i
, unescaped
);
2488 ok(!wcscmp(bufferW
, TEST_URL_UNESCAPEW
[i
].expect
), "[%d]: got result %s.\n", i
, debugstr_w(bufferW
));
2490 /* Test with URL_UNESCAPE_INPLACE */
2491 unescaped
= INTERNET_MAX_URL_LENGTH
;
2492 res
= UrlUnescapeW(urlW
, NULL
, &unescaped
, TEST_URL_UNESCAPEW
[i
].flags
| URL_UNESCAPE_INPLACE
);
2493 ok(res
== S_OK
, "[%d]: returned %#lx.\n", i
, res
);
2494 ok(unescaped
== INTERNET_MAX_URL_LENGTH
, "[%d]: got unescaped %ld.\n", i
, unescaped
);
2495 ok(!wcscmp(urlW
, TEST_URL_UNESCAPEW
[i
].expect
), "[%d]: got result %s.\n", i
, debugstr_w(urlW
));
2497 lstrcpyW(urlW
, TEST_URL_UNESCAPEW
[i
].url
);
2498 unescaped
= wcslen(TEST_URL_UNESCAPEW
[i
].expect
) - 1;
2499 res
= UrlUnescapeW(urlW
, bufferW
, &unescaped
, TEST_URL_UNESCAPEW
[i
].flags
);
2500 ok(res
== E_POINTER
, "[%d]: returned %#lx.\n", i
, res
);
2503 dwEscaped
= sizeof(inplace
);
2504 res
= UrlUnescapeA(inplace
, NULL
, &dwEscaped
, URL_UNESCAPE_INPLACE
);
2505 ok(res
== S_OK
, "UrlUnescapeA returned 0x%lx (expected S_OK)\n", res
);
2506 ok(!strcmp(inplace
, expected
), "got %s expected %s\n", inplace
, expected
);
2507 ok(dwEscaped
== 27, "got %ld expected 27\n", dwEscaped
);
2509 /* if we set the buffer pointer to NULL, the string apparently still gets converted (Google Lively does this) */
2510 res
= UrlUnescapeA(another_inplace
, NULL
, NULL
, URL_UNESCAPE_INPLACE
);
2511 ok(res
== S_OK
, "UrlUnescapeA returned 0x%lx (expected S_OK)\n", res
);
2512 ok(!strcmp(another_inplace
, expected
), "got %s expected %s\n", another_inplace
, expected
);
2515 static const struct parse_url_test_t
{
2520 } parse_url_tests
[] = {
2521 {"http://www.winehq.org/",S_OK
,4,URL_SCHEME_HTTP
},
2522 {"https://www.winehq.org/",S_OK
,5,URL_SCHEME_HTTPS
},
2523 {"ftp://www.winehq.org/",S_OK
,3,URL_SCHEME_FTP
},
2524 {"test.txt?test=c:/dir",URL_E_INVALID_SYNTAX
},
2525 {"test.txt",URL_E_INVALID_SYNTAX
},
2526 {"xxx://www.winehq.org/",S_OK
,3,URL_SCHEME_UNKNOWN
},
2527 {"1xx://www.winehq.org/",S_OK
,3,URL_SCHEME_UNKNOWN
},
2528 {"-xx://www.winehq.org/",S_OK
,3,URL_SCHEME_UNKNOWN
},
2529 {"xx0://www.winehq.org/",S_OK
,3,URL_SCHEME_UNKNOWN
},
2530 {"x://www.winehq.org/",URL_E_INVALID_SYNTAX
},
2531 {"xx$://www.winehq.org/",URL_E_INVALID_SYNTAX
},
2532 {"htt?p://www.winehq.org/",URL_E_INVALID_SYNTAX
},
2533 {"ab-://www.winehq.org/",S_OK
,3,URL_SCHEME_UNKNOWN
},
2534 {" http://www.winehq.org/",URL_E_INVALID_SYNTAX
},
2535 {"HTTP://www.winehq.org/",S_OK
,4,URL_SCHEME_HTTP
},
2536 {"a+-.://www.winehq.org/",S_OK
,4,URL_SCHEME_UNKNOWN
},
2539 static void test_ParseURL(void)
2541 const struct parse_url_test_t
*test
;
2542 WCHAR url
[INTERNET_MAX_URL_LENGTH
];
2547 for (test
= parse_url_tests
; test
< parse_url_tests
+ ARRAY_SIZE(parse_url_tests
); test
++) {
2548 memset(&parseda
, 0xd0, sizeof(parseda
));
2549 parseda
.cbSize
= sizeof(parseda
);
2550 hres
= ParseURLA(test
->url
, &parseda
);
2551 ok(hres
== test
->hres
, "ParseURL failed: %08lx, expected %08lx\n", hres
, test
->hres
);
2553 ok(parseda
.pszProtocol
== test
->url
, "parseda.pszProtocol = %s, expected %s\n",
2554 parseda
.pszProtocol
, test
->url
);
2555 ok(parseda
.cchProtocol
== test
->protocol_len
, "parseda.cchProtocol = %d, expected %d\n",
2556 parseda
.cchProtocol
, test
->protocol_len
);
2557 ok(parseda
.pszSuffix
== test
->url
+test
->protocol_len
+1, "parseda.pszSuffix = %s, expected %s\n",
2558 parseda
.pszSuffix
, test
->url
+test
->protocol_len
+1);
2559 ok(parseda
.cchSuffix
== strlen(test
->url
+test
->protocol_len
+1),
2560 "parseda.pszSuffix = %d, expected %d\n",
2561 parseda
.cchSuffix
, lstrlenA(test
->url
+test
->protocol_len
+1));
2562 ok(parseda
.nScheme
== test
->scheme
, "parseda.nScheme = %d, expected %d\n",
2563 parseda
.nScheme
, test
->scheme
);
2565 ok(!parseda
.pszProtocol
, "parseda.pszProtocol = %p\n", parseda
.pszProtocol
);
2566 ok(parseda
.nScheme
== 0xd0d0d0d0, "nScheme = %d\n", parseda
.nScheme
);
2569 MultiByteToWideChar(CP_ACP
, 0, test
->url
, -1, url
, ARRAY_SIZE(url
));
2571 memset(&parsedw
, 0xd0, sizeof(parsedw
));
2572 parsedw
.cbSize
= sizeof(parsedw
);
2573 hres
= ParseURLW(url
, &parsedw
);
2574 ok(hres
== test
->hres
, "ParseURL failed: %08lx, expected %08lx\n", hres
, test
->hres
);
2576 ok(parsedw
.pszProtocol
== url
, "parsedw.pszProtocol = %s, expected %s\n",
2577 wine_dbgstr_w(parsedw
.pszProtocol
), wine_dbgstr_w(url
));
2578 ok(parsedw
.cchProtocol
== test
->protocol_len
, "parsedw.cchProtocol = %d, expected %d\n",
2579 parsedw
.cchProtocol
, test
->protocol_len
);
2580 ok(parsedw
.pszSuffix
== url
+test
->protocol_len
+1, "parsedw.pszSuffix = %s, expected %s\n",
2581 wine_dbgstr_w(parsedw
.pszSuffix
), wine_dbgstr_w(url
+test
->protocol_len
+1));
2582 ok(parsedw
.cchSuffix
== strlen(test
->url
+test
->protocol_len
+1),
2583 "parsedw.pszSuffix = %d, expected %d\n",
2584 parsedw
.cchSuffix
, lstrlenA(test
->url
+test
->protocol_len
+1));
2585 ok(parsedw
.nScheme
== test
->scheme
, "parsedw.nScheme = %d, expected %d\n",
2586 parsedw
.nScheme
, test
->scheme
);
2588 ok(!parsedw
.pszProtocol
, "parsedw.pszProtocol = %p\n", parseda
.pszProtocol
);
2589 ok(parsedw
.nScheme
== 0xd0d0d0d0, "nScheme = %d\n", parsedw
.nScheme
);
2594 static void test_HashData(void)
2597 BYTE input
[16] = {0x51, 0x33, 0x4F, 0xA7, 0x45, 0x15, 0xF0, 0x52, 0x90,
2598 0x2B, 0xE7, 0xF5, 0xFD, 0xE1, 0xA6, 0xA7};
2600 static const BYTE expected
[] = {0x54, 0x9C, 0x92, 0x55, 0xCD, 0x82, 0xFF,
2601 0xA1, 0x8E, 0x0F, 0xCF, 0x93, 0x14, 0xAA,
2603 static const BYTE expected2
[] = {0x54, 0x9C, 0x92, 0x55, 0xCD, 0x82, 0xFF,
2604 0xA1, 0x8E, 0x0F, 0xCF, 0x93, 0x14, 0xAA,
2605 0xE3, 0x2D, 0x47, 0xFC, 0x80, 0xB8, 0xD0,
2606 0x49, 0xE6, 0x13, 0x2A, 0x30, 0x51, 0x8D,
2607 0xF9, 0x4B, 0x07, 0xA6};
2608 static const BYTE expected3
[] = {0x2B, 0xDC, 0x9A, 0x1B, 0xF0, 0x5A, 0xF9,
2609 0xC6, 0xBE, 0x94, 0x6D, 0xF3, 0x33, 0xC1,
2613 /* Test hashing with identically sized input/output buffers. */
2614 res
= HashData(input
, 16, output
, 16);
2615 ok(res
== S_OK
, "Expected HashData to return S_OK, got 0x%08lx\n", res
);
2616 ok(!memcmp(output
, expected
, sizeof(expected
)), "data didn't match\n");
2618 /* Test hashing with larger output buffer. */
2619 res
= HashData(input
, 16, output
, 32);
2620 ok(res
== S_OK
, "Expected HashData to return S_OK, got 0x%08lx\n", res
);
2621 ok(!memcmp(output
, expected2
, sizeof(expected2
)), "data didn't match\n");
2623 /* Test hashing with smaller input buffer. */
2624 res
= HashData(input
, 8, output
, 16);
2625 ok(res
== S_OK
, "Expected HashData to return S_OK, got 0x%08lx\n", res
);
2626 ok(!memcmp(output
, expected3
, sizeof(expected3
)), "data didn't match\n");
2628 /* Test passing NULL pointers for input/output parameters. */
2629 res
= HashData(NULL
, 0, NULL
, 0);
2630 ok(res
== E_INVALIDARG
, "Got unexpected hr %#lx.\n", res
);
2632 res
= HashData(input
, 0, NULL
, 0);
2633 ok(res
== E_INVALIDARG
, "Got unexpected hr %#lx.\n", res
);
2635 res
= HashData(NULL
, 0, output
, 0);
2636 ok(res
== E_INVALIDARG
, "Got unexpected hr %#lx.\n", res
);
2638 /* Test passing valid pointers with sizes of zero. */
2639 for (i
= 0; i
< ARRAY_SIZE(input
); i
++)
2642 for (i
= 0; i
< ARRAY_SIZE(output
); i
++)
2645 res
= HashData(input
, 0, output
, 0);
2646 ok(res
== S_OK
, "Expected HashData to return S_OK, got 0x%08lx\n", res
);
2648 /* The buffers should be unchanged. */
2649 for (i
= 0; i
< ARRAY_SIZE(input
); i
++)
2650 ok(input
[i
] == 0x00, "Expected the input buffer to be unchanged\n");
2652 for (i
= 0; i
< ARRAY_SIZE(output
); i
++)
2653 ok(output
[i
] == 0xFF, "Expected the output buffer to be unchanged\n");
2655 /* Input/output parameters are not validated. */
2656 res
= HashData((BYTE
*)0xdeadbeef, 0, (BYTE
*)0xdeadbeef, 0);
2657 ok(res
== S_OK
, "Expected HashData to return S_OK, got 0x%08lx\n", res
);
2661 res
= HashData((BYTE
*)0xdeadbeef, 1, (BYTE
*)0xdeadbeef, 1);
2662 trace("HashData returned 0x%08lx\n", res
);
2666 /* ########################### */
2670 test_UrlApplyScheme();
2673 test_UrlCanonicalizeA();
2674 test_UrlCanonicalizeW();
2678 test_UrlCreateFromPath();