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"
32 /* ################ */
33 static HMODULE hShlwapi
;
34 static HRESULT (WINAPI
*pUrlUnescapeA
)(LPSTR
,LPSTR
,LPDWORD
,DWORD
);
35 static HRESULT (WINAPI
*pUrlUnescapeW
)(LPWSTR
,LPWSTR
,LPDWORD
,DWORD
);
36 static BOOL (WINAPI
*pUrlIsA
)(LPCSTR
,URLIS
);
37 static BOOL (WINAPI
*pUrlIsW
)(LPCWSTR
,URLIS
);
38 static HRESULT (WINAPI
*pUrlHashA
)(LPCSTR
,LPBYTE
,DWORD
);
39 static HRESULT (WINAPI
*pUrlHashW
)(LPCWSTR
,LPBYTE
,DWORD
);
40 static HRESULT (WINAPI
*pUrlGetPartA
)(LPCSTR
,LPSTR
,LPDWORD
,DWORD
,DWORD
);
41 static HRESULT (WINAPI
*pUrlGetPartW
)(LPCWSTR
,LPWSTR
,LPDWORD
,DWORD
,DWORD
);
42 static HRESULT (WINAPI
*pUrlEscapeA
)(LPCSTR
,LPSTR
,LPDWORD
,DWORD
);
43 static HRESULT (WINAPI
*pUrlEscapeW
)(LPCWSTR
,LPWSTR
,LPDWORD
,DWORD
);
44 static HRESULT (WINAPI
*pUrlCreateFromPathA
)(LPCSTR
,LPSTR
,LPDWORD
,DWORD
);
45 static HRESULT (WINAPI
*pUrlCreateFromPathW
)(LPCWSTR
,LPWSTR
,LPDWORD
,DWORD
);
46 static HRESULT (WINAPI
*pUrlCombineA
)(LPCSTR
,LPCSTR
,LPSTR
,LPDWORD
,DWORD
);
47 static HRESULT (WINAPI
*pUrlCombineW
)(LPCWSTR
,LPCWSTR
,LPWSTR
,LPDWORD
,DWORD
);
48 static HRESULT (WINAPI
*pUrlCanonicalizeA
)(LPCSTR
, LPSTR
, LPDWORD
, DWORD
);
49 static HRESULT (WINAPI
*pUrlCanonicalizeW
)(LPCWSTR
, LPWSTR
, LPDWORD
, DWORD
);
50 static HRESULT (WINAPI
*pUrlApplySchemeA
)(LPCSTR
,LPSTR
,LPDWORD
,DWORD
);
51 static HRESULT (WINAPI
*pUrlApplySchemeW
)(LPCWSTR
,LPWSTR
,LPDWORD
,DWORD
);
52 static HRESULT (WINAPI
*pParseURLA
)(LPCSTR
,PARSEDURLA
*);
53 static HRESULT (WINAPI
*pParseURLW
)(LPCWSTR
,PARSEDURLW
*);
54 static HRESULT (WINAPI
*pHashData
)(LPBYTE
, DWORD
, LPBYTE
, DWORD
);
56 static const char* TEST_URL_1
= "http://www.winehq.org/tests?date=10/10/1923";
57 static const char* TEST_URL_2
= "http://localhost:8080/tests%2e.html?date=Mon%2010/10/1923";
58 static const char* TEST_URL_3
= "http://foo:bar@localhost:21/internal.php?query=x&return=y";
59 static const char* TEST_URL_4
= "http://foo:bar@google.*.com:21/internal.php?query=x&return=y";
61 static const WCHAR winehqW
[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/',0};
62 static const CHAR winehqA
[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/',0};
64 /* ################ */
66 static const CHAR untouchedA
[] = "untouched";
68 #define TEST_APPLY_MAX_LENGTH INTERNET_MAX_URL_LENGTH
70 typedef struct _TEST_URL_APPLY
{
78 static const TEST_URL_APPLY TEST_APPLY
[] = {
79 {"www.winehq.org", URL_APPLY_GUESSSCHEME
| URL_APPLY_DEFAULT
, S_OK
, 21, "http://www.winehq.org"},
80 {"www.winehq.org", URL_APPLY_GUESSSCHEME
, S_OK
, 21, "http://www.winehq.org"},
81 {"www.winehq.org", URL_APPLY_DEFAULT
, S_OK
, 21, "http://www.winehq.org"},
82 {"ftp.winehq.org", URL_APPLY_GUESSSCHEME
| URL_APPLY_DEFAULT
, S_OK
, 20, "ftp://ftp.winehq.org"},
83 {"ftp.winehq.org", URL_APPLY_GUESSSCHEME
, S_OK
, 20, "ftp://ftp.winehq.org"},
84 {"ftp.winehq.org", URL_APPLY_DEFAULT
, S_OK
, 21, "http://ftp.winehq.org"},
85 {"winehq.org", URL_APPLY_GUESSSCHEME
| URL_APPLY_DEFAULT
, S_OK
, 17, "http://winehq.org"},
86 {"winehq.org", URL_APPLY_GUESSSCHEME
, S_FALSE
, TEST_APPLY_MAX_LENGTH
, untouchedA
},
87 {"winehq.org", URL_APPLY_DEFAULT
, S_OK
, 17, "http://winehq.org"},
88 {"http://www.winehq.org", URL_APPLY_GUESSSCHEME
, S_FALSE
, TEST_APPLY_MAX_LENGTH
, untouchedA
},
89 {"http://www.winehq.org", URL_APPLY_GUESSSCHEME
| URL_APPLY_FORCEAPPLY
, S_FALSE
, TEST_APPLY_MAX_LENGTH
, untouchedA
},
90 {"http://www.winehq.org", URL_APPLY_GUESSSCHEME
| URL_APPLY_FORCEAPPLY
| URL_APPLY_DEFAULT
, S_OK
, 28, "http://http://www.winehq.org"},
91 {"http://www.winehq.org", URL_APPLY_GUESSSCHEME
| URL_APPLY_DEFAULT
, S_FALSE
, TEST_APPLY_MAX_LENGTH
, untouchedA
},
92 {"", URL_APPLY_GUESSSCHEME
| URL_APPLY_DEFAULT
, S_OK
, 7, "http://"},
93 {"", URL_APPLY_GUESSSCHEME
, S_FALSE
, TEST_APPLY_MAX_LENGTH
, untouchedA
},
94 {"", URL_APPLY_DEFAULT
, S_OK
, 7, "http://"},
95 {"u:\\windows", URL_APPLY_GUESSFILE
| URL_APPLY_DEFAULT
, S_OK
, 18, "file:///u:/windows"},
96 {"u:\\windows", URL_APPLY_GUESSFILE
, S_OK
, 18, "file:///u:/windows"},
97 {"u:\\windows", URL_APPLY_DEFAULT
, S_OK
, 17, "http://u:\\windows"},
98 {"file:///c:/windows", URL_APPLY_GUESSFILE
, S_FALSE
, TEST_APPLY_MAX_LENGTH
, untouchedA
},
99 {"aa:\\windows", URL_APPLY_GUESSFILE
, S_FALSE
, TEST_APPLY_MAX_LENGTH
, untouchedA
},
102 /* ################ */
104 typedef struct _TEST_URL_CANONICALIZE
{
108 const char *expecturl
;
110 } TEST_URL_CANONICALIZE
;
112 static const TEST_URL_CANONICALIZE TEST_CANONICALIZE
[] = {
113 {"http://www.winehq.org/tests/../tests/../..", 0, S_OK
, "http://www.winehq.org/", TRUE
},
114 {"http://www.winehq.org/..", 0, S_OK
, "http://www.winehq.org/..", FALSE
},
115 {"http://www.winehq.org/tests/tests2/../../tests", 0, S_OK
, "http://www.winehq.org/tests", FALSE
},
116 {"http://www.winehq.org/tests/../tests", 0, S_OK
, "http://www.winehq.org/tests", FALSE
},
117 {"http://www.winehq.org/tests\n", URL_WININET_COMPATIBILITY
|URL_ESCAPE_SPACES_ONLY
|URL_ESCAPE_UNSAFE
, S_OK
, "http://www.winehq.org/tests", FALSE
},
118 {"http://www.winehq.org/tests\r", URL_WININET_COMPATIBILITY
|URL_ESCAPE_SPACES_ONLY
|URL_ESCAPE_UNSAFE
, S_OK
, "http://www.winehq.org/tests", FALSE
},
119 {"http://www.winehq.org/tests\r", 0, S_OK
, "http://www.winehq.org/tests", FALSE
},
120 {"http://www.winehq.org/tests\r", URL_DONT_SIMPLIFY
, S_OK
, "http://www.winehq.org/tests", FALSE
},
121 {"http://www.winehq.org/tests/../tests/", 0, S_OK
, "http://www.winehq.org/tests/", FALSE
},
122 {"http://www.winehq.org/tests/../tests/..", 0, S_OK
, "http://www.winehq.org/", FALSE
},
123 {"http://www.winehq.org/tests/../tests/../", 0, S_OK
, "http://www.winehq.org/", FALSE
},
124 {"http://www.winehq.org/tests/..", 0, S_OK
, "http://www.winehq.org/", FALSE
},
125 {"http://www.winehq.org/tests/../", 0, S_OK
, "http://www.winehq.org/", FALSE
},
126 {"http://www.winehq.org/tests/..?query=x&return=y", 0, S_OK
, "http://www.winehq.org/?query=x&return=y", FALSE
},
127 {"http://www.winehq.org/tests/../?query=x&return=y", 0, S_OK
, "http://www.winehq.org/?query=x&return=y", FALSE
},
128 {"\tht\ttp\t://www\t.w\tineh\t\tq.or\tg\t/\ttests/..\t?\tquer\ty=x\t\t&re\tturn=y\t\t", 0, S_OK
, "http://www.winehq.org/?query=x&return=y", FALSE
},
129 {"http://www.winehq.org/tests/..#example", 0, S_OK
, "http://www.winehq.org/#example", FALSE
},
130 {"http://www.winehq.org/tests/../#example", 0, S_OK
, "http://www.winehq.org/#example", FALSE
},
131 {"http://www.winehq.org/tests\\../#example", 0, S_OK
, "http://www.winehq.org/#example", FALSE
},
132 {"http://www.winehq.org/tests/..\\#example", 0, S_OK
, "http://www.winehq.org/#example", FALSE
},
133 {"http://www.winehq.org\\tests/../#example", 0, S_OK
, "http://www.winehq.org/#example", FALSE
},
134 {"http://www.winehq.org/tests/../#example", URL_DONT_SIMPLIFY
, S_OK
, "http://www.winehq.org/tests/../#example", FALSE
},
135 {"http://www.winehq.org/tests/foo bar", URL_ESCAPE_SPACES_ONLY
| URL_DONT_ESCAPE_EXTRA_INFO
, S_OK
, "http://www.winehq.org/tests/foo%20bar", FALSE
},
136 {"http://www.winehq.org/tests/foo%20bar", URL_UNESCAPE
, S_OK
, "http://www.winehq.org/tests/foo bar", FALSE
},
137 {"http://www.winehq.org", 0, S_OK
, "http://www.winehq.org/", FALSE
},
138 {"http:///www.winehq.org", 0, S_OK
, "http:///www.winehq.org", FALSE
},
139 {"http:////www.winehq.org", 0, S_OK
, "http:////www.winehq.org", FALSE
},
140 {"file:///c:/tests/foo%20bar", URL_UNESCAPE
, S_OK
, "file:///c:/tests/foo bar", FALSE
},
141 {"file:///c:/tests\\foo%20bar", URL_UNESCAPE
, S_OK
, "file:///c:/tests/foo bar", FALSE
},
142 {"file:///c:/tests/foo%20bar", 0, S_OK
, "file:///c:/tests/foo%20bar", FALSE
},
143 {"file:///c:/tests/foo%20bar", URL_FILE_USE_PATHURL
, S_OK
, "file://c:\\tests\\foo bar", FALSE
},
144 {"file://localhost/c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL
, S_OK
, "file://c:\\tests\\foo bar", FALSE
},
145 {"file://localhost\\c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL
, S_OK
, "file://c:\\tests\\foo bar", FALSE
},
146 {"file://localhost\\\\c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL
, S_OK
, "file://c:\\tests\\foo bar", FALSE
},
147 {"file://localhost\\c:\\tests/../tests/foo%20bar", URL_FILE_USE_PATHURL
, S_OK
, "file://c:\\tests\\foo bar", FALSE
},
148 {"file://c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL
, S_OK
, "file://c:\\tests\\foo bar", FALSE
},
149 {"file://c:/tests\\../tests/foo%20bar", URL_FILE_USE_PATHURL
, S_OK
, "file://c:\\tests\\foo bar", FALSE
},
150 {"file://c:/tests/foo%20bar", URL_FILE_USE_PATHURL
, S_OK
, "file://c:\\tests\\foo bar", FALSE
},
151 {"file:///c://tests/foo%20bar", URL_FILE_USE_PATHURL
, S_OK
, "file://c:\\\\tests\\foo bar", FALSE
},
152 {"file:///c:\\tests\\foo bar", 0, S_OK
, "file:///c:/tests/foo bar", FALSE
},
153 {"file:///c:\\tests\\foo bar", URL_DONT_SIMPLIFY
, S_OK
, "file:///c:/tests/foo bar", FALSE
},
154 {"file:///c:\\tests\\foobar", 0, S_OK
, "file:///c:/tests/foobar", FALSE
},
155 {"file:///c:\\tests\\foobar", URL_WININET_COMPATIBILITY
, S_OK
, "file://c:\\tests\\foobar", FALSE
},
156 {"file://home/user/file", 0, S_OK
, "file://home/user/file", FALSE
},
157 {"file:///home/user/file", 0, S_OK
, "file:///home/user/file", FALSE
},
158 {"file:////home/user/file", 0, S_OK
, "file://home/user/file", FALSE
},
159 {"file://home/user/file", URL_WININET_COMPATIBILITY
, S_OK
, "file://\\\\home\\user\\file", FALSE
},
160 {"file:///home/user/file", URL_WININET_COMPATIBILITY
, S_OK
, "file://\\home\\user\\file", FALSE
},
161 {"file:////home/user/file", URL_WININET_COMPATIBILITY
, S_OK
, "file://\\\\home\\user\\file", FALSE
},
162 {"file://///home/user/file", URL_WININET_COMPATIBILITY
, S_OK
, "file://\\\\home\\user\\file", FALSE
},
163 {"file://C:/user/file", 0, S_OK
, "file:///C:/user/file", FALSE
},
164 {"file://C:/user/file/../asdf", 0, S_OK
, "file:///C:/user/asdf", FALSE
},
165 {"file:///C:/user/file", 0, S_OK
, "file:///C:/user/file", FALSE
},
166 {"file:////C:/user/file", 0, S_OK
, "file:///C:/user/file", FALSE
},
167 {"file://C:/user/file", URL_WININET_COMPATIBILITY
, S_OK
, "file://C:\\user\\file", FALSE
},
168 {"file:///C:/user/file", URL_WININET_COMPATIBILITY
, S_OK
, "file://C:\\user\\file", FALSE
},
169 {"file:////C:/user/file", URL_WININET_COMPATIBILITY
, S_OK
, "file://C:\\user\\file", FALSE
},
170 {"http:///www.winehq.org", 0, S_OK
, "http:///www.winehq.org", FALSE
},
171 {"http:///www.winehq.org", URL_WININET_COMPATIBILITY
, S_OK
, "http:///www.winehq.org", FALSE
},
172 {"http://www.winehq.org/site/about", URL_FILE_USE_PATHURL
, S_OK
, "http://www.winehq.org/site/about", FALSE
},
173 {"file_://www.winehq.org/site/about", URL_FILE_USE_PATHURL
, S_OK
, "file_://www.winehq.org/site/about", FALSE
},
174 {"c:\\dir\\file", 0, S_OK
, "file:///c:/dir/file", FALSE
},
175 {"file:///c:\\dir\\file", 0, S_OK
, "file:///c:/dir/file", FALSE
},
176 {"c:dir\\file", 0, S_OK
, "file:///c:dir/file", FALSE
},
177 {"c:\\tests\\foo bar", URL_FILE_USE_PATHURL
, S_OK
, "file://c:\\tests\\foo bar", FALSE
},
178 {"c:\\tests\\foo bar", 0, S_OK
, "file:///c:/tests/foo%20bar", FALSE
},
179 {"c\t:\t\\te\tsts\\fo\to \tbar\t", 0, S_OK
, "file:///c:/tests/foo%20bar", FALSE
},
180 {"res://file", 0, S_OK
, "res://file/", FALSE
},
181 {"res://file", URL_FILE_USE_PATHURL
, S_OK
, "res://file/", FALSE
},
182 {"res:///c:/tests/foo%20bar", URL_UNESCAPE
, S_OK
, "res:///c:/tests/foo bar", FALSE
},
183 {"res:///c:/tests\\foo%20bar", URL_UNESCAPE
, S_OK
, "res:///c:/tests\\foo bar", FALSE
},
184 {"res:///c:/tests/foo%20bar", 0, S_OK
, "res:///c:/tests/foo%20bar", FALSE
},
185 {"res:///c:/tests/foo%20bar", URL_FILE_USE_PATHURL
, S_OK
, "res:///c:/tests/foo%20bar", FALSE
},
186 {"res://c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL
, S_OK
, "res://c:/tests/foo%20bar", FALSE
},
187 {"res://c:/tests\\../tests/foo%20bar", URL_FILE_USE_PATHURL
, S_OK
, "res://c:/tests/foo%20bar", FALSE
},
188 {"res://c:/tests/foo%20bar", URL_FILE_USE_PATHURL
, S_OK
, "res://c:/tests/foo%20bar", FALSE
},
189 {"res:///c://tests/foo%20bar", URL_FILE_USE_PATHURL
, S_OK
, "res:///c://tests/foo%20bar", FALSE
},
190 {"res:///c:\\tests\\foo bar", 0, S_OK
, "res:///c:\\tests\\foo bar", FALSE
},
191 {"res:///c:\\tests\\foo bar", URL_DONT_SIMPLIFY
, S_OK
, "res:///c:\\tests\\foo bar", FALSE
},
192 {"res://c:\\tests\\foo bar/res", URL_FILE_USE_PATHURL
, S_OK
, "res://c:\\tests\\foo bar/res", FALSE
},
193 {"res://c:\\tests/res\\foo%20bar/strange\\sth", 0, S_OK
, "res://c:\\tests/res\\foo%20bar/strange\\sth", FALSE
},
194 {"res://c:\\tests/res\\foo%20bar/strange\\sth", URL_FILE_USE_PATHURL
, S_OK
, "res://c:\\tests/res\\foo%20bar/strange\\sth", FALSE
},
195 {"res://c:\\tests/res\\foo%20bar/strange\\sth", URL_UNESCAPE
, S_OK
, "res://c:\\tests/res\\foo bar/strange\\sth", FALSE
},
196 {"A", 0, S_OK
, "A", FALSE
},
197 {"../A", 0, S_OK
, "../A", FALSE
},
198 {"A/../B", 0, S_OK
, "B", TRUE
},
199 {"/uri-res/N2R?urn:sha1:B3K", URL_DONT_ESCAPE_EXTRA_INFO
| URL_WININET_COMPATIBILITY
/*0x82000000*/, S_OK
, "/uri-res/N2R?urn:sha1:B3K", FALSE
} /*LimeWire online installer calls this*/,
200 {"http:www.winehq.org/dir/../index.html", 0, S_OK
, "http:www.winehq.org/index.html"},
201 {"http://localhost/test.html", URL_FILE_USE_PATHURL
, S_OK
, "http://localhost/test.html"},
202 {"http://localhost/te%20st.html", URL_FILE_USE_PATHURL
, S_OK
, "http://localhost/te%20st.html"},
203 {"http://www.winehq.org/%E6%A1%9C.html", URL_FILE_USE_PATHURL
, S_OK
, "http://www.winehq.org/%E6%A1%9C.html"},
204 {"mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm", 0, S_OK
, "mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm"},
205 {"ftp:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm", 0, S_OK
, "ftp:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm"},
206 {"file:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm", 0, S_OK
, "file:@MSITStore:C:/Program Files/AutoCAD 2008/Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm"},
207 {"http:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm", 0, S_OK
, "http:@MSITStore:C:/Program Files/AutoCAD 2008/Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm"},
208 {"http:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm", URL_FILE_USE_PATHURL
, S_OK
, "http:@MSITStore:C:/Program Files/AutoCAD 2008/Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm"},
209 {"mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm", URL_FILE_USE_PATHURL
, S_OK
, "mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm"},
212 /* ################ */
214 typedef struct _TEST_URL_ESCAPE
{
219 const char *expecturl
;
222 static const TEST_URL_ESCAPE TEST_ESCAPE
[] = {
223 {"http://www.winehq.org/tests0", 0, 0, S_OK
, "http://www.winehq.org/tests0"},
224 {"http://www.winehq.org/tests1\n", 0, 0, S_OK
, "http://www.winehq.org/tests1%0A"},
225 {"http://www.winehq.org/tests2\r", 0, 0, S_OK
, "http://www.winehq.org/tests2%0D"},
226 {"http://www.winehq.org/tests3\r", URL_ESCAPE_SPACES_ONLY
|URL_ESCAPE_UNSAFE
, 0, S_OK
, "http://www.winehq.org/tests3\r"},
227 {"http://www.winehq.org/tests4\r", URL_ESCAPE_SPACES_ONLY
, 0, S_OK
, "http://www.winehq.org/tests4\r"},
228 {"http://www.winehq.org/tests5\r", URL_WININET_COMPATIBILITY
|URL_ESCAPE_SPACES_ONLY
, 0, S_OK
, "http://www.winehq.org/tests5\r"},
229 {"/direct/swhelp/series6/6.2i_latestservicepack.dat\r", URL_ESCAPE_SPACES_ONLY
, 0, S_OK
, "/direct/swhelp/series6/6.2i_latestservicepack.dat\r"},
231 {"file://////foo/bar\\baz", 0, 0, S_OK
, "file://foo/bar/baz"},
232 {"file://///foo/bar\\baz", 0, 0, S_OK
, "file://foo/bar/baz"},
233 {"file:////foo/bar\\baz", 0, 0, S_OK
, "file://foo/bar/baz"},
234 {"file:///localhost/foo/bar\\baz", 0, 0, S_OK
, "file:///localhost/foo/bar/baz"},
235 {"file:///foo/bar\\baz", 0, 0, S_OK
, "file:///foo/bar/baz"},
236 {"file://loCalHost/foo/bar\\baz", 0, 0, S_OK
, "file:///foo/bar/baz"},
237 {"file://foo/bar\\baz", 0, 0, S_OK
, "file://foo/bar/baz"},
238 {"file:/localhost/foo/bar\\baz", 0, 0, S_OK
, "file:///localhost/foo/bar/baz"},
239 {"file:/foo/bar\\baz", 0, 0, S_OK
, "file:///foo/bar/baz"},
240 {"file:foo/bar\\baz", 0, 0, S_OK
, "file:foo/bar/baz"},
241 {"file:\\foo/bar\\baz", 0, 0, S_OK
, "file:///foo/bar/baz"},
242 {"file:\\\\foo/bar\\baz", 0, 0, S_OK
, "file://foo/bar/baz"},
243 {"file:\\\\\\foo/bar\\baz", 0, 0, S_OK
, "file:///foo/bar/baz"},
244 {"file:\\\\localhost\\foo/bar\\baz", 0, 0, S_OK
, "file:///foo/bar/baz"},
245 {"file:///f oo/b?a r\\baz", 0, 0, S_OK
, "file:///f%20oo/b?a r\\baz"},
246 {"file:///foo/b#a r\\baz", 0, 0, S_OK
, "file:///foo/b%23a%20r/baz"},
247 {"file:///f o^&`{}|][\"<>\\%o/b#a r\\baz", 0, 0, S_OK
, "file:///f%20o%5E%26%60%7B%7D%7C%5D%5B%22%3C%3E/%o/b%23a%20r/baz"},
248 {"file:///f o%o/b?a r\\b%az", URL_ESCAPE_PERCENT
, 0, S_OK
, "file:///f%20o%25o/b?a r\\b%az"},
249 {"file:/foo/bar\\baz", URL_ESCAPE_SEGMENT_ONLY
, 0, S_OK
, "file:%2Ffoo%2Fbar%5Cbaz"},
251 {"foo/b%ar\\ba?z\\", URL_ESCAPE_SEGMENT_ONLY
, 0, S_OK
, "foo%2Fb%ar%5Cba%3Fz%5C"},
252 {"foo/b%ar\\ba?z\\", URL_ESCAPE_PERCENT
| URL_ESCAPE_SEGMENT_ONLY
, 0, S_OK
, "foo%2Fb%25ar%5Cba%3Fz%5C"},
253 {"foo/bar\\ba?z\\", 0, 0, S_OK
, "foo/bar%5Cba?z\\"},
254 {"/foo/bar\\ba?z\\", 0, 0, S_OK
, "/foo/bar%5Cba?z\\"},
255 {"/foo/bar\\ba#z\\", 0, 0, S_OK
, "/foo/bar%5Cba#z\\"},
256 {"/foo/%5C", 0, 0, S_OK
, "/foo/%5C"},
257 {"/foo/%5C", URL_ESCAPE_PERCENT
, 0, S_OK
, "/foo/%255C"},
259 {"http://////foo/bar\\baz", 0, 0, S_OK
, "http://////foo/bar/baz"},
260 {"http://///foo/bar\\baz", 0, 0, S_OK
, "http://///foo/bar/baz"},
261 {"http:////foo/bar\\baz", 0, 0, S_OK
, "http:////foo/bar/baz"},
262 {"http:///foo/bar\\baz", 0, 0, S_OK
, "http:///foo/bar/baz"},
263 {"http://localhost/foo/bar\\baz", 0, 0, S_OK
, "http://localhost/foo/bar/baz"},
264 {"http://foo/bar\\baz", 0, 0, S_OK
, "http://foo/bar/baz"},
265 {"http:/foo/bar\\baz", 0, 0, S_OK
, "http:/foo/bar/baz"},
266 {"http:foo/bar\\ba?z\\", 0, 0, S_OK
, "http:foo%2Fbar%2Fba?z\\"},
267 {"http:foo/bar\\ba#z\\", 0, 0, S_OK
, "http:foo%2Fbar%2Fba#z\\"},
268 {"http:\\foo/bar\\baz", 0, 0, S_OK
, "http:/foo/bar/baz"},
269 {"http:\\\\foo/bar\\baz", 0, 0, S_OK
, "http://foo/bar/baz"},
270 {"http:\\\\\\foo/bar\\baz", 0, 0, S_OK
, "http:///foo/bar/baz"},
271 {"http:\\\\\\\\foo/bar\\baz", 0, 0, S_OK
, "http:////foo/bar/baz"},
272 {"http:/fo ?o/b ar\\baz", 0, 0, S_OK
, "http:/fo%20?o/b ar\\baz"},
273 {"http:fo ?o/b ar\\baz", 0, 0, S_OK
, "http:fo%20?o/b ar\\baz"},
274 {"http:/foo/bar\\baz", URL_ESCAPE_SEGMENT_ONLY
, 0, S_OK
, "http:%2Ffoo%2Fbar%5Cbaz"},
276 {"https://foo/bar\\baz", 0, 0, S_OK
, "https://foo/bar/baz"},
277 {"https:/foo/bar\\baz", 0, 0, S_OK
, "https:/foo/bar/baz"},
278 {"https:\\foo/bar\\baz", 0, 0, S_OK
, "https:/foo/bar/baz"},
280 {"foo:////foo/bar\\baz", 0, 0, S_OK
, "foo:////foo/bar%5Cbaz"},
281 {"foo:///foo/bar\\baz", 0, 0, S_OK
, "foo:///foo/bar%5Cbaz"},
282 {"foo://localhost/foo/bar\\baz", 0, 0, S_OK
, "foo://localhost/foo/bar%5Cbaz"},
283 {"foo://foo/bar\\baz", 0, 0, S_OK
, "foo://foo/bar%5Cbaz"},
284 {"foo:/foo/bar\\baz", 0, 0, S_OK
, "foo:/foo/bar%5Cbaz"},
285 {"foo:foo/bar\\baz", 0, 0, S_OK
, "foo:foo%2Fbar%5Cbaz"},
286 {"foo:\\foo/bar\\baz", 0, 0, S_OK
, "foo:%5Cfoo%2Fbar%5Cbaz"},
287 {"foo:/foo/bar\\ba?\\z", 0, 0, S_OK
, "foo:/foo/bar%5Cba?\\z"},
288 {"foo:/foo/bar\\ba#\\z", 0, 0, S_OK
, "foo:/foo/bar%5Cba#\\z"},
290 {"mailto:/fo/o@b\\%a?\\r.b#\\az", 0, 0, S_OK
, "mailto:%2Ffo%2Fo@b%5C%a%3F%5Cr.b%23%5Caz"},
291 {"mailto:fo/o@b\\%a?\\r.b#\\az", 0, 0, S_OK
, "mailto:fo%2Fo@b%5C%a%3F%5Cr.b%23%5Caz"},
292 {"mailto:fo/o@b\\%a?\\r.b#\\az", URL_ESCAPE_PERCENT
, 0, S_OK
, "mailto:fo%2Fo@b%5C%25a%3F%5Cr.b%23%5Caz"},
294 {"ftp:fo/o@bar.baz/foo/bar", 0, 0, S_OK
, "ftp:fo%2Fo@bar.baz%2Ffoo%2Fbar"},
295 {"ftp:/fo/o@bar.baz/foo/bar", 0, 0, S_OK
, "ftp:/fo/o@bar.baz/foo/bar"},
296 {"ftp://fo/o@bar.baz/fo?o\\bar", 0, 0, S_OK
, "ftp://fo/o@bar.baz/fo?o\\bar"},
297 {"ftp://fo/o@bar.baz/fo#o\\bar", 0, 0, S_OK
, "ftp://fo/o@bar.baz/fo#o\\bar"},
298 {"ftp://localhost/o@bar.baz/fo#o\\bar", 0, 0, S_OK
, "ftp://localhost/o@bar.baz/fo#o\\bar"},
299 {"ftp:///fo/o@bar.baz/foo/bar", 0, 0, S_OK
, "ftp:///fo/o@bar.baz/foo/bar"},
300 {"ftp:////fo/o@bar.baz/foo/bar", 0, 0, S_OK
, "ftp:////fo/o@bar.baz/foo/bar"},
302 {"ftp\x1f\1end/", 0, 0, S_OK
, "ftp%1F%01end/"}
305 typedef struct _TEST_URL_ESCAPEW
{
306 const WCHAR url
[INTERNET_MAX_URL_LENGTH
];
309 const WCHAR expecturl
[INTERNET_MAX_URL_LENGTH
];
310 const WCHAR win7url
[INTERNET_MAX_URL_LENGTH
]; /* <= Win7 */
311 const WCHAR vistaurl
[INTERNET_MAX_URL_LENGTH
]; /* <= Vista/2k8 */
314 static const TEST_URL_ESCAPEW TEST_ESCAPEW
[] = {
315 {{' ','<','>','"',0}, URL_ESCAPE_AS_UTF8
, S_OK
, {'%','2','0','%','3','C','%','3','E','%','2','2',0}},
316 {{'{','}','|','\\',0}, URL_ESCAPE_AS_UTF8
, S_OK
, {'%','7','B','%','7','D','%','7','C','%','5','C',0}},
317 {{'^',']','[','`',0}, URL_ESCAPE_AS_UTF8
, S_OK
, {'%','5','E','%','5','D','%','5','B','%','6','0',0}},
318 {{'&','/','?','#',0}, URL_ESCAPE_AS_UTF8
, S_OK
, {'%','2','6','/','?','#',0}},
319 {{'M','a','s','s',0}, URL_ESCAPE_AS_UTF8
, S_OK
, {'M','a','s','s',0}},
321 /* broken < Win8/10 */
323 {{'M','a',0xdf,0}, URL_ESCAPE_AS_UTF8
, S_OK
, {'M','a','%','C','3','%','9','F',0},
324 {'M','a','%','D','F',0}},
326 {{0xd841,0xdf0e,0}, URL_ESCAPE_AS_UTF8
, S_OK
, {'%','F','0','%','A','0','%','9','C','%','8','E',0},
327 {'%','E','F','%','B','F','%','B','D','%','E','F','%','B','F','%','B','D',0},
330 {{0xd85e,0xde3e,0}, URL_ESCAPE_AS_UTF8
, S_OK
, {'%','F','0','%','A','7','%','A','8','%','B','E',0},
331 {'%','E','F','%','B','F','%','B','D','%','E','F','%','B','F','%','B','D',0},
334 {{0xd85e,0}, URL_ESCAPE_AS_UTF8
, S_OK
, {'%','E','F','%','B','F','%','B','D',0},
336 {{0xd85e,0x41}, URL_ESCAPE_AS_UTF8
, S_OK
, {'%','E','F','%','B','F','%','B','D','A',0},
338 {{0xdc00,0}, URL_ESCAPE_AS_UTF8
, S_OK
, {'%','E','F','%','B','F','%','B','D',0},
340 {{0xffff,0}, URL_ESCAPE_AS_UTF8
, S_OK
, {'%','E','F','%','B','F','%','B','F',0},
344 /* ################ */
346 typedef struct _TEST_URL_COMBINE
{
351 const char *expecturl
;
354 static const TEST_URL_COMBINE TEST_COMBINE
[] = {
355 {"http://www.winehq.org/tests", "tests1", 0, S_OK
, "http://www.winehq.org/tests1"},
356 {"http://www.%77inehq.org/tests", "tests1", 0, S_OK
, "http://www.%77inehq.org/tests1"},
357 /*FIXME {"http://www.winehq.org/tests", "../tests2", 0, S_OK, "http://www.winehq.org/tests2"},*/
358 {"http://www.winehq.org/tests/", "../tests3", 0, S_OK
, "http://www.winehq.org/tests3"},
359 {"http://www.winehq.org/tests/test1", "test2", 0, S_OK
, "http://www.winehq.org/tests/test2"},
360 {"http://www.winehq.org/tests/../tests", "tests4", 0, S_OK
, "http://www.winehq.org/tests4"},
361 {"http://www.winehq.org/tests/../tests/", "tests5", 0, S_OK
, "http://www.winehq.org/tests/tests5"},
362 {"http://www.winehq.org/tests/../tests/", "/tests6/..", 0, S_OK
, "http://www.winehq.org/"},
363 {"http://www.winehq.org/tests/../tests/..", "tests7/..", 0, S_OK
, "http://www.winehq.org/"},
364 {"http://www.winehq.org/tests/?query=x&return=y", "tests8", 0, S_OK
, "http://www.winehq.org/tests/tests8"},
365 {"http://www.winehq.org/tests/#example", "tests9", 0, S_OK
, "http://www.winehq.org/tests/tests9"},
366 {"http://www.winehq.org/tests/../tests/", "/tests10/..", URL_DONT_SIMPLIFY
, S_OK
, "http://www.winehq.org/tests10/.."},
367 {"http://www.winehq.org/tests/../", "tests11", URL_DONT_SIMPLIFY
, S_OK
, "http://www.winehq.org/tests/../tests11"},
368 {"http://www.winehq.org/test12", "#", 0, S_OK
, "http://www.winehq.org/test12#"},
369 {"http://www.winehq.org/test13#aaa", "#bbb", 0, S_OK
, "http://www.winehq.org/test13#bbb"},
370 {"http://www.winehq.org/test14#aaa/bbb#ccc", "#", 0, S_OK
, "http://www.winehq.org/test14#"},
371 {"http://www.winehq.org/tests/?query=x/y/z", "tests15", 0, S_OK
, "http://www.winehq.org/tests/tests15"},
372 {"http://www.winehq.org/tests/?query=x/y/z#example", "tests16", 0, S_OK
, "http://www.winehq.org/tests/tests16"},
373 {"file:///C:\\dir\\file.txt", "test.txt", 0, S_OK
, "file:///C:/dir/test.txt"},
374 {"file:///C:\\dir\\file.txt#hash\\hash", "test.txt", 0, S_OK
, "file:///C:/dir/file.txt#hash/test.txt"},
375 {"file:///C:\\dir\\file.html#hash\\hash", "test.html", 0, S_OK
, "file:///C:/dir/test.html"},
376 {"file:///C:\\dir\\file.htm#hash\\hash", "test.htm", 0, S_OK
, "file:///C:/dir/test.htm"},
377 {"file:///C:\\dir\\file.hTmL#hash\\hash", "test.hTmL", 0, S_OK
, "file:///C:/dir/test.hTmL"},
378 {"file:///C:\\dir.html\\file.txt#hash\\hash", "test.txt", 0, S_OK
, "file:///C:/dir.html/file.txt#hash/test.txt"},
379 {"C:\\winehq\\winehq.txt", "C:\\Test\\test.txt", 0, S_OK
, "file:///C:/Test/test.txt"},
380 {"http://www.winehq.org/test/", "test%20file.txt", 0, S_OK
, "http://www.winehq.org/test/test%20file.txt"},
381 {"http://www.winehq.org/test/", "test%20file.txt", URL_FILE_USE_PATHURL
, S_OK
, "http://www.winehq.org/test/test%20file.txt"},
382 {"http://www.winehq.org%2ftest/", "test%20file.txt", URL_FILE_USE_PATHURL
, S_OK
, "http://www.winehq.org%2ftest/test%20file.txt"},
383 {"xxx:@MSITStore:file.chm/file.html", "dir/file", 0, S_OK
, "xxx:dir/file"},
384 {"mk:@MSITStore:file.chm::/file.html", "/dir/file", 0, S_OK
, "mk:@MSITStore:file.chm::/dir/file"},
385 {"mk:@MSITStore:file.chm::/file.html", "mk:@MSITStore:file.chm::/dir/file", 0, S_OK
, "mk:@MSITStore:file.chm::/dir/file"},
386 {"foo:today", "foo:calendar", 0, S_OK
, "foo:calendar"},
387 {"foo:today", "bar:calendar", 0, S_OK
, "bar:calendar"},
388 {"foo:/today", "foo:calendar", 0, S_OK
, "foo:/calendar"},
389 {"Foo:/today/", "fOo:calendar", 0, S_OK
, "foo:/today/calendar"},
390 {"mk:@MSITStore:dir/test.chm::dir/index.html", "image.jpg", 0, S_OK
, "mk:@MSITStore:dir/test.chm::dir/image.jpg"},
391 {"mk:@MSITStore:dir/test.chm::dir/dir2/index.html", "../image.jpg", 0, S_OK
, "mk:@MSITStore:dir/test.chm::dir/image.jpg"},
392 /* UrlCombine case 2 tests. Schemes do not match */
393 {"outbind://xxxxxxxxx","http://wine1/dir",0, S_OK
,"http://wine1/dir"},
394 {"xxxx://xxxxxxxxx","http://wine2/dir",0, S_OK
,"http://wine2/dir"},
395 {"ftp://xxxxxxxxx/","http://wine3/dir",0, S_OK
,"http://wine3/dir"},
396 {"outbind://xxxxxxxxx","http://wine4/dir",URL_PLUGGABLE_PROTOCOL
, S_OK
,"http://wine4/dir"},
397 {"xxx://xxxxxxxxx","http://wine5/dir",URL_PLUGGABLE_PROTOCOL
, S_OK
,"http://wine5/dir"},
398 {"ftp://xxxxxxxxx/","http://wine6/dir",URL_PLUGGABLE_PROTOCOL
, S_OK
,"http://wine6/dir"},
399 {"http://xxxxxxxxx","outbind://wine7/dir",0, S_OK
,"outbind://wine7/dir"},
400 {"xxx://xxxxxxxxx","ftp://wine8/dir",0, S_OK
,"ftp://wine8/dir"},
401 {"ftp://xxxxxxxxx/","xxx://wine9/dir",0, S_OK
,"xxx://wine9/dir"},
402 {"http://xxxxxxxxx","outbind://wine10/dir",URL_PLUGGABLE_PROTOCOL
, S_OK
,"outbind://wine10/dir"},
403 {"xxx://xxxxxxxxx","ftp://wine11/dir",URL_PLUGGABLE_PROTOCOL
, S_OK
,"ftp://wine11/dir"},
404 {"ftp://xxxxxxxxx/","xxx://wine12/dir",URL_PLUGGABLE_PROTOCOL
, S_OK
,"xxx://wine12/dir"},
405 {"http://xxxxxxxxx","outbind:wine13/dir",0, S_OK
,"outbind:wine13/dir"},
406 {"xxx://xxxxxxxxx","ftp:wine14/dir",0, S_OK
,"ftp:wine14/dir"},
407 {"ftp://xxxxxxxxx/","xxx:wine15/dir",0, S_OK
,"xxx:wine15/dir"},
408 {"outbind://xxxxxxxxx/","http:wine16/dir",0, S_OK
,"http:wine16/dir"},
409 {"http://xxxxxxxxx","outbind:wine17/dir",URL_PLUGGABLE_PROTOCOL
, S_OK
,"outbind:wine17/dir"},
410 {"xxx://xxxxxxxxx","ftp:wine18/dir",URL_PLUGGABLE_PROTOCOL
, S_OK
,"ftp:wine18/dir"},
411 {"ftp://xxxxxxxxx/","xXx:wine19/dir",URL_PLUGGABLE_PROTOCOL
, S_OK
,"xxx:wine19/dir"},
412 {"outbind://xxxxxxxxx/","http:wine20/dir",URL_PLUGGABLE_PROTOCOL
, S_OK
,"http:wine20/dir"},
413 {"file:///c:/dir/file.txt","index.html?test=c:/abc",URL_ESCAPE_SPACES_ONLY
|URL_DONT_ESCAPE_EXTRA_INFO
,S_OK
,"file:///c:/dir/index.html?test=c:/abc"}
416 /* ################ */
418 static const struct {
422 } TEST_URLFROMPATH
[] = {
423 {"foo", "file:foo", S_OK
},
424 {"foo\\bar", "file:foo/bar", S_OK
},
425 {"\\foo\\bar", "file:///foo/bar", S_OK
},
426 {"c:\\foo\\bar", "file:///c:/foo/bar", S_OK
},
427 {"c:foo\\bar", "file:///c:foo/bar", S_OK
},
428 {"c:\\foo/b a%r", "file:///c:/foo/b%20a%25r", S_OK
},
429 {"c:\\foo\\foo bar", "file:///c:/foo/foo%20bar", S_OK
},
430 {"file:///c:/foo/bar", "file:///c:/foo/bar", S_FALSE
},
432 /* The following test fails on native shlwapi as distributed with Win95/98.
433 * Wine matches the behaviour of later versions.
435 {"xx:c:\\foo\\bar", "xx:c:\\foo\\bar", S_FALSE
}
439 /* ################ */
444 } TEST_URL_UNESCAPE
[] = {
445 {"file://foo/bar", "file://foo/bar"},
446 {"file://fo%20o%5Ca/bar", "file://fo o\\a/bar"},
447 {"file://%24%25foobar", "file://$%foobar"}
450 /* ################ */
452 static const struct {
455 } TEST_PATH_IS_URL
[] = {
456 {"http://foo/bar", TRUE
},
457 {"c:\\foo\\bar", FALSE
},
458 {"foo://foo/bar", TRUE
},
461 {"bogusscheme:", TRUE
},
462 {"http:partial", TRUE
}
465 /* ################ */
467 static const struct {
471 } TEST_URLIS_ATTRIBS
[] = {
472 { "ftp:", FALSE
, FALSE
},
473 { "http:", FALSE
, FALSE
},
474 { "gopher:", FALSE
, FALSE
},
475 { "mailto:", TRUE
, FALSE
},
476 { "news:", FALSE
, FALSE
},
477 { "nntp:", FALSE
, FALSE
},
478 { "telnet:", FALSE
, FALSE
},
479 { "wais:", FALSE
, FALSE
},
480 { "file:", FALSE
, TRUE
},
481 { "mk:", FALSE
, FALSE
},
482 { "https:", FALSE
, FALSE
},
483 { "shell:", TRUE
, FALSE
},
484 { "https:", FALSE
, FALSE
},
485 { "snews:", FALSE
, FALSE
},
486 { "local:", FALSE
, FALSE
},
487 { "javascript:", TRUE
, FALSE
},
488 { "vbscript:", TRUE
, FALSE
},
489 { "about:", TRUE
, FALSE
},
490 { "res:", FALSE
, FALSE
},
491 { "bogusscheme:", FALSE
, FALSE
},
492 { "file:\\\\e:\\b\\c", FALSE
, TRUE
},
493 { "file://e:/b/c", FALSE
, TRUE
},
494 { "http:partial", FALSE
, FALSE
},
495 { "mailto://www.winehq.org/test.html", TRUE
, FALSE
},
496 { "file:partial", FALSE
, TRUE
},
497 { "File:partial", FALSE
, TRUE
},
500 /* ########################### */
502 static LPWSTR
GetWideString(const char* szString
)
504 LPWSTR wszString
= HeapAlloc(GetProcessHeap(), 0, (2*INTERNET_MAX_URL_LENGTH
) * sizeof(WCHAR
));
506 MultiByteToWideChar(CP_ACP
, 0, szString
, -1, wszString
, INTERNET_MAX_URL_LENGTH
);
512 static void FreeWideString(LPWSTR wszString
)
514 HeapFree(GetProcessHeap(), 0, wszString
);
517 /* ########################### */
519 static void test_UrlApplyScheme(void)
521 CHAR newurl
[TEST_APPLY_MAX_LENGTH
];
522 WCHAR urlW
[TEST_APPLY_MAX_LENGTH
];
523 WCHAR newurlW
[TEST_APPLY_MAX_LENGTH
];
528 if (!pUrlApplySchemeA
) {
529 win_skip("UrlApplySchemeA not found\n");
533 for(i
= 0; i
< sizeof(TEST_APPLY
)/sizeof(TEST_APPLY
[0]); i
++) {
534 len
= TEST_APPLY_MAX_LENGTH
;
535 lstrcpyA(newurl
, untouchedA
);
536 res
= pUrlApplySchemeA(TEST_APPLY
[i
].url
, newurl
, &len
, TEST_APPLY
[i
].flags
);
537 ok( res
== TEST_APPLY
[i
].res
,
538 "#%dA: got HRESULT 0x%x (expected 0x%x)\n", i
, res
, TEST_APPLY
[i
].res
);
540 ok( len
== TEST_APPLY
[i
].newlen
,
541 "#%dA: got len %d (expected %d)\n", i
, len
, TEST_APPLY
[i
].newlen
);
543 ok( !lstrcmpA(newurl
, TEST_APPLY
[i
].newurl
),
544 "#%dA: got '%s' (expected '%s')\n", i
, newurl
, TEST_APPLY
[i
].newurl
);
546 /* returned length is in character */
547 len
= TEST_APPLY_MAX_LENGTH
;
548 lstrcpyA(newurl
, untouchedA
);
549 MultiByteToWideChar(CP_ACP
, 0, newurl
, -1, newurlW
, len
);
550 MultiByteToWideChar(CP_ACP
, 0, TEST_APPLY
[i
].url
, -1, urlW
, len
);
552 res
= pUrlApplySchemeW(urlW
, newurlW
, &len
, TEST_APPLY
[i
].flags
);
553 WideCharToMultiByte(CP_ACP
, 0, newurlW
, -1, newurl
, TEST_APPLY_MAX_LENGTH
, NULL
, NULL
);
554 ok( res
== TEST_APPLY
[i
].res
,
555 "#%dW: got HRESULT 0x%x (expected 0x%x)\n", i
, res
, TEST_APPLY
[i
].res
);
557 ok( len
== TEST_APPLY
[i
].newlen
,
558 "#%dW: got len %d (expected %d)\n", i
, len
, TEST_APPLY
[i
].newlen
);
560 ok( !lstrcmpA(newurl
, TEST_APPLY
[i
].newurl
),
561 "#%dW: got '%s' (expected '%s')\n", i
, newurl
, TEST_APPLY
[i
].newurl
);
565 /* buffer too small */
566 lstrcpyA(newurl
, untouchedA
);
567 len
= lstrlenA(TEST_APPLY
[0].newurl
);
568 res
= pUrlApplySchemeA(TEST_APPLY
[0].url
, newurl
, &len
, TEST_APPLY
[0].flags
);
569 ok(res
== E_POINTER
, "got HRESULT 0x%x (expected E_POINTER)\n", res
);
570 /* The returned length include the space for the terminating 0 */
571 i
= lstrlenA(TEST_APPLY
[0].newurl
)+1;
572 ok(len
== i
, "got len %d (expected %d)\n", len
, i
);
573 ok(!lstrcmpA(newurl
, untouchedA
), "got '%s' (expected '%s')\n", newurl
, untouchedA
);
575 /* NULL as parameter. The length and the buffer are not modified */
576 lstrcpyA(newurl
, untouchedA
);
577 len
= TEST_APPLY_MAX_LENGTH
;
578 res
= pUrlApplySchemeA(NULL
, newurl
, &len
, TEST_APPLY
[0].flags
);
579 ok(res
== E_INVALIDARG
, "got HRESULT 0x%x (expected E_INVALIDARG)\n", res
);
580 ok(len
== TEST_APPLY_MAX_LENGTH
, "got len %d\n", len
);
581 ok(!lstrcmpA(newurl
, untouchedA
), "got '%s' (expected '%s')\n", newurl
, untouchedA
);
583 len
= TEST_APPLY_MAX_LENGTH
;
584 res
= pUrlApplySchemeA(TEST_APPLY
[0].url
, NULL
, &len
, TEST_APPLY
[0].flags
);
585 ok(res
== E_INVALIDARG
, "got HRESULT 0x%x (expected E_INVALIDARG)\n", res
);
586 ok(len
== TEST_APPLY_MAX_LENGTH
, "got len %d\n", len
);
588 lstrcpyA(newurl
, untouchedA
);
589 res
= pUrlApplySchemeA(TEST_APPLY
[0].url
, newurl
, NULL
, TEST_APPLY
[0].flags
);
590 ok(res
== E_INVALIDARG
, "got HRESULT 0x%x (expected E_INVALIDARG)\n", res
);
591 ok(!lstrcmpA(newurl
, untouchedA
), "got '%s' (expected '%s')\n", newurl
, untouchedA
);
595 /* ########################### */
597 static void hash_url(const char* szUrl
)
599 LPCSTR szTestUrl
= szUrl
;
600 LPWSTR wszTestUrl
= GetWideString(szTestUrl
);
603 DWORD cbSize
= sizeof(DWORD
);
604 DWORD dwHash1
, dwHash2
;
605 res
= pUrlHashA(szTestUrl
, (LPBYTE
)&dwHash1
, cbSize
);
606 ok(res
== S_OK
, "UrlHashA returned 0x%x (expected S_OK) for %s\n", res
, szUrl
);
608 res
= pUrlHashW(wszTestUrl
, (LPBYTE
)&dwHash2
, cbSize
);
609 ok(res
== S_OK
, "UrlHashW returned 0x%x (expected S_OK) for %s\n", res
, szUrl
);
610 ok(dwHash1
== dwHash2
,
611 "Hashes didn't match (A: 0x%x, W: 0x%x) for %s\n", dwHash1
, dwHash2
, szUrl
);
613 FreeWideString(wszTestUrl
);
617 static void test_UrlHash(void)
620 win_skip("UrlHashA not found\n");
624 hash_url(TEST_URL_1
);
625 hash_url(TEST_URL_2
);
626 hash_url(TEST_URL_3
);
629 /* ########################### */
631 static void test_url_part(const char* szUrl
, DWORD dwPart
, DWORD dwFlags
, const char* szExpected
)
633 CHAR szPart
[INTERNET_MAX_URL_LENGTH
];
634 WCHAR wszPart
[INTERNET_MAX_URL_LENGTH
];
635 LPWSTR wszUrl
= GetWideString(szUrl
);
636 LPWSTR wszConvertedPart
;
641 res
= pUrlGetPartA(szUrl
, szPart
, &dwSize
, dwPart
, dwFlags
);
642 ok(res
== E_POINTER
, "UrlGetPart for \"%s\" gave: 0x%08x\n", szUrl
, res
);
643 ok(dwSize
== strlen(szExpected
)+1 ||
644 (*szExpected
== '?' && dwSize
== strlen(szExpected
)),
645 "UrlGetPart for \"%s\" gave size: %u\n", szUrl
, dwSize
);
647 dwSize
= INTERNET_MAX_URL_LENGTH
;
648 res
= pUrlGetPartA(szUrl
, szPart
, &dwSize
, dwPart
, dwFlags
);
650 "UrlGetPartA for \"%s\" part 0x%08x returned 0x%x and \"%s\"\n",
651 szUrl
, dwPart
, res
, szPart
);
653 dwSize
= INTERNET_MAX_URL_LENGTH
;
654 res
= pUrlGetPartW(wszUrl
, wszPart
, &dwSize
, dwPart
, dwFlags
);
656 "UrlGetPartW for \"%s\" part 0x%08x returned 0x%x\n",
659 wszConvertedPart
= GetWideString(szPart
);
661 ok(lstrcmpW(wszPart
,wszConvertedPart
)==0,
662 "Strings didn't match between ascii and unicode UrlGetPart!\n");
664 FreeWideString(wszConvertedPart
);
666 FreeWideString(wszUrl
);
668 /* Note that v6.0 and later don't return '?' with the query */
669 ok(strcmp(szPart
,szExpected
)==0 ||
670 (*szExpected
=='?' && !strcmp(szPart
,szExpected
+1)),
671 "Expected %s, but got %s\n", szExpected
, szPart
);
674 /* ########################### */
676 static void test_UrlGetPart(void)
678 const char* file_url
= "file://h o s t/c:/windows/file";
679 const char* http_url
= "http://user:pass 123@www.wine hq.org";
680 const char* res_url
= "res://some.dll/find.dlg";
681 const char* about_url
= "about:blank";
682 const char* excid_url
= "x-excid://36C00000/guid:{048B4E89-2E92-496F-A837-33BA02FF6D32}/Message.htm";
683 const char* foo_url
= "foo://bar-url/test";
684 const char* short_url
= "ascheme:";
686 CHAR szPart
[INTERNET_MAX_URL_LENGTH
];
691 win_skip("UrlGetPartA not found\n");
695 res
= pUrlGetPartA(NULL
, NULL
, NULL
, URL_PART_SCHEME
, 0);
696 ok(res
== E_INVALIDARG
, "null params gave: 0x%08x\n", res
);
698 res
= pUrlGetPartA(NULL
, szPart
, &dwSize
, URL_PART_SCHEME
, 0);
699 ok(res
== E_INVALIDARG
, "null URL gave: 0x%08x\n", res
);
701 res
= pUrlGetPartA(res_url
, NULL
, &dwSize
, URL_PART_SCHEME
, 0);
702 ok(res
== E_INVALIDARG
, "null szPart gave: 0x%08x\n", res
);
704 res
= pUrlGetPartA(res_url
, szPart
, NULL
, URL_PART_SCHEME
, 0);
705 ok(res
== E_INVALIDARG
, "null URL gave: 0x%08x\n", res
);
708 szPart
[0]='x'; szPart
[1]=0;
709 res
= pUrlGetPartA("hi", szPart
, &dwSize
, URL_PART_SCHEME
, 0);
710 ok(res
== E_INVALIDARG
, "UrlGetPartA(*pcchOut = 0) returned %08X\n", res
);
711 ok(szPart
[0] == 'x' && szPart
[1] == 0, "UrlGetPartA(*pcchOut = 0) modified szPart: \"%s\"\n", szPart
);
712 ok(dwSize
== 0, "dwSize = %d\n", dwSize
);
714 dwSize
= sizeof szPart
;
715 szPart
[0]='x'; szPart
[1]=0;
716 res
= pUrlGetPartA("hi", szPart
, &dwSize
, URL_PART_SCHEME
, 0);
717 ok (res
==S_FALSE
, "UrlGetPartA(\"hi\") returned %08X\n", res
);
718 ok(szPart
[0]==0, "UrlGetPartA(\"hi\") return \"%s\" instead of \"\"\n", szPart
);
719 ok(dwSize
== 0, "dwSize = %d\n", dwSize
);
723 const WCHAR hiW
[] = {'h','i',0};
726 /* UrlGetPartW returns S_OK instead of S_FALSE */
727 dwSize
= sizeof szPart
;
728 bufW
[0]='x'; bufW
[1]=0;
729 res
= pUrlGetPartW(hiW
, bufW
, &dwSize
, URL_PART_SCHEME
, 0);
730 todo_wine
ok(res
==S_OK
, "UrlGetPartW(\"hi\") returned %08X\n", res
);
731 ok(bufW
[0] == 0, "UrlGetPartW(\"hi\") return \"%c\"\n", bufW
[0]);
732 ok(dwSize
== 0, "dwSize = %d\n", dwSize
);
735 dwSize
= sizeof szPart
;
736 szPart
[0]='x'; szPart
[1]=0;
737 res
= pUrlGetPartA("hi", szPart
, &dwSize
, URL_PART_QUERY
, 0);
738 ok (res
==S_FALSE
, "UrlGetPartA(\"hi\") returned %08X\n", res
);
739 ok(szPart
[0]==0, "UrlGetPartA(\"hi\") return \"%s\" instead of \"\"\n", szPart
);
740 ok(dwSize
== 0, "dwSize = %d\n", dwSize
);
742 test_url_part(TEST_URL_3
, URL_PART_HOSTNAME
, 0, "localhost");
743 test_url_part(TEST_URL_3
, URL_PART_PORT
, 0, "21");
744 test_url_part(TEST_URL_3
, URL_PART_USERNAME
, 0, "foo");
745 test_url_part(TEST_URL_3
, URL_PART_PASSWORD
, 0, "bar");
746 test_url_part(TEST_URL_3
, URL_PART_SCHEME
, 0, "http");
747 test_url_part(TEST_URL_3
, URL_PART_QUERY
, 0, "?query=x&return=y");
749 test_url_part(TEST_URL_4
, URL_PART_HOSTNAME
, 0, "google.*.com");
751 test_url_part(file_url
, URL_PART_HOSTNAME
, 0, "h o s t");
753 test_url_part(http_url
, URL_PART_HOSTNAME
, 0, "www.wine hq.org");
754 test_url_part(http_url
, URL_PART_PASSWORD
, 0, "pass 123");
756 test_url_part(about_url
, URL_PART_SCHEME
, 0, "about");
758 test_url_part(excid_url
, URL_PART_SCHEME
, 0, "x-excid");
759 test_url_part(foo_url
, URL_PART_SCHEME
, 0, "foo");
760 test_url_part(short_url
, URL_PART_SCHEME
, 0, "ascheme");
762 dwSize
= sizeof(szPart
);
763 res
= pUrlGetPartA(about_url
, szPart
, &dwSize
, URL_PART_HOSTNAME
, 0);
764 ok(res
==E_FAIL
, "returned %08x\n", res
);
766 test_url_part(res_url
, URL_PART_SCHEME
, 0, "res");
767 test_url_part("http://www.winehq.org", URL_PART_HOSTNAME
, URL_PARTFLAG_KEEPSCHEME
, "http:www.winehq.org");
769 dwSize
= sizeof szPart
;
770 szPart
[0]='x'; szPart
[1]=0;
771 res
= pUrlGetPartA(res_url
, szPart
, &dwSize
, URL_PART_QUERY
, 0);
772 ok(res
==S_FALSE
, "UrlGetPartA returned %08X\n", res
);
773 ok(szPart
[0]==0, "UrlGetPartA gave \"%s\" instead of \"\"\n", szPart
);
774 ok(dwSize
== 0, "dwSize = %d\n", dwSize
);
776 dwSize
= sizeof(szPart
);
777 res
= pUrlGetPartA("file://c:\\index.htm", szPart
, &dwSize
, URL_PART_HOSTNAME
, 0);
778 ok(res
==S_FALSE
, "returned %08x\n", res
);
779 ok(dwSize
== 0, "dwSize = %d\n", dwSize
);
781 dwSize
= sizeof(szPart
);
782 szPart
[0] = 'x'; szPart
[1] = '\0';
783 res
= pUrlGetPartA("file:some text", szPart
, &dwSize
, URL_PART_HOSTNAME
, 0);
784 ok(res
==S_FALSE
, "returned %08x\n", res
);
785 ok(szPart
[0] == '\0', "szPart[0] = %c\n", szPart
[0]);
786 ok(dwSize
== 0, "dwSize = %d\n", dwSize
);
788 dwSize
= sizeof(szPart
);
789 szPart
[0] = 'x'; szPart
[1] = '\0';
790 res
= pUrlGetPartA("index.htm", szPart
, &dwSize
, URL_PART_HOSTNAME
, 0);
791 ok(res
==E_FAIL
, "returned %08x\n", res
);
793 dwSize
= sizeof(szPart
);
794 szPart
[0] = 'x'; szPart
[1] = '\0';
795 res
= pUrlGetPartA(excid_url
, szPart
, &dwSize
, URL_PART_HOSTNAME
, 0);
796 ok(res
==E_FAIL
, "returned %08x\n", res
);
797 ok(szPart
[0] == 'x', "szPart[0] = %c\n", szPart
[0]);
798 ok(dwSize
== sizeof(szPart
), "dwSize = %d\n", dwSize
);
800 dwSize
= sizeof(szPart
);
801 szPart
[0] = 'x'; szPart
[1] = '\0';
802 res
= pUrlGetPartA(excid_url
, szPart
, &dwSize
, URL_PART_QUERY
, 0);
803 ok(res
==S_FALSE
, "returned %08x\n", res
);
804 ok(szPart
[0] == 0, "szPart[0] = %c\n", szPart
[0]);
805 ok(dwSize
== 0, "dwSize = %d\n", dwSize
);
807 dwSize
= sizeof(szPart
);
808 szPart
[0] = 'x'; szPart
[1] = '\0';
809 res
= pUrlGetPartA(foo_url
, szPart
, &dwSize
, URL_PART_HOSTNAME
, 0);
810 ok(res
==E_FAIL
, "returned %08x\n", res
);
811 ok(szPart
[0] == 'x', "szPart[0] = %c\n", szPart
[0]);
812 ok(dwSize
== sizeof(szPart
), "dwSize = %d\n", dwSize
);
814 dwSize
= sizeof(szPart
);
815 szPart
[0] = 'x'; szPart
[1] = '\0';
816 res
= pUrlGetPartA(foo_url
, szPart
, &dwSize
, URL_PART_QUERY
, 0);
817 ok(res
==S_FALSE
, "returned %08x\n", res
);
818 ok(szPart
[0] == 0, "szPart[0] = %c\n", szPart
[0]);
819 ok(dwSize
== 0, "dwSize = %d\n", dwSize
);
822 /* ########################### */
823 static void test_url_canonicalize(int index
, const char *szUrl
, DWORD dwFlags
, HRESULT dwExpectReturn
, HRESULT dwExpectReturnAlt
, const char *szExpectUrl
, BOOL todo
)
825 CHAR szReturnUrl
[INTERNET_MAX_URL_LENGTH
];
826 WCHAR wszReturnUrl
[INTERNET_MAX_URL_LENGTH
];
827 LPWSTR wszUrl
= GetWideString(szUrl
);
828 LPWSTR wszExpectUrl
= GetWideString(szExpectUrl
);
829 LPWSTR wszConvertedUrl
;
834 dwSize
= INTERNET_MAX_URL_LENGTH
;
835 ret
= pUrlCanonicalizeA(szUrl
, NULL
, &dwSize
, dwFlags
);
836 ok(ret
!= dwExpectReturn
, "got 0s%x: Unexpected return for NULL buffer, index %d\n", ret
, index
);
837 ret
= pUrlCanonicalizeA(szUrl
, szReturnUrl
, &dwSize
, dwFlags
);
838 ok(ret
== dwExpectReturn
|| ret
== dwExpectReturnAlt
,
839 "UrlCanonicalizeA failed: expected=0x%08x or 0x%08x, got=0x%08x, index %d\n",
840 dwExpectReturn
, dwExpectReturnAlt
, ret
, index
);
842 ok(strcmp(szReturnUrl
,szExpectUrl
)==0, "UrlCanonicalizeA dwFlags 0x%08x url '%s' Expected \"%s\", but got \"%s\", index %d\n", dwFlags
, szUrl
, szExpectUrl
, szReturnUrl
, index
);
844 if (pUrlCanonicalizeW
) {
845 dwSize
= INTERNET_MAX_URL_LENGTH
;
846 ret
= pUrlCanonicalizeW(wszUrl
, NULL
, &dwSize
, dwFlags
);
847 ok(ret
!= dwExpectReturn
, "got 0x%x: Unexpected return for NULL buffer, index %d\n", ret
, index
);
848 ret
= pUrlCanonicalizeW(wszUrl
, wszReturnUrl
, &dwSize
, dwFlags
);
849 ok(ret
== dwExpectReturn
, "UrlCanonicalizeW failed: expected 0x%08x, got 0x%x, index %d\n",
850 dwExpectReturn
, ret
, index
);
852 wszConvertedUrl
= GetWideString(szReturnUrl
);
853 ok(lstrcmpW(wszReturnUrl
, wszConvertedUrl
)==0,
854 "Strings didn't match between ascii and unicode UrlCanonicalize, index %d!\n", index
);
855 FreeWideString(wszConvertedUrl
);
858 FreeWideString(wszUrl
);
859 FreeWideString(wszExpectUrl
);
863 static void test_UrlEscapeA(void)
868 char empty_string
[] = "";
871 win_skip("UrlEscapeA not found\n");
875 ret
= pUrlEscapeA("/woningplan/woonkamer basis.swf", NULL
, &size
, URL_ESCAPE_SPACES_ONLY
);
876 ok(ret
== E_INVALIDARG
, "got %x, expected %x\n", ret
, E_INVALIDARG
);
877 ok(size
== 0, "got %d, expected %d\n", size
, 0);
880 ret
= pUrlEscapeA("/woningplan/woonkamer basis.swf", empty_string
, &size
, URL_ESCAPE_SPACES_ONLY
);
881 ok(ret
== E_INVALIDARG
, "got %x, expected %x\n", ret
, E_INVALIDARG
);
882 ok(size
== 0, "got %d, expected %d\n", size
, 0);
885 ret
= pUrlEscapeA("/woningplan/woonkamer basis.swf", NULL
, &size
, URL_ESCAPE_SPACES_ONLY
);
886 ok(ret
== E_INVALIDARG
, "got %x, expected %x\n", ret
, E_INVALIDARG
);
887 ok(size
== 1, "got %d, expected %d\n", size
, 1);
890 ret
= pUrlEscapeA("/woningplan/woonkamer basis.swf", empty_string
, NULL
, URL_ESCAPE_SPACES_ONLY
);
891 ok(ret
== E_INVALIDARG
, "got %x, expected %x\n", ret
, E_INVALIDARG
);
892 ok(size
== 1, "got %d, expected %d\n", size
, 1);
895 empty_string
[0] = 127;
896 ret
= pUrlEscapeA("/woningplan/woonkamer basis.swf", empty_string
, &size
, URL_ESCAPE_SPACES_ONLY
);
897 ok(ret
== E_POINTER
, "got %x, expected %x\n", ret
, E_POINTER
);
898 ok(size
== 34, "got %d, expected %d\n", size
, 34);
899 ok(empty_string
[0] == 127, "String has changed, empty_string[0] = %d\n", empty_string
[0]);
902 empty_string
[0] = 127;
903 ret
= pUrlEscapeA("/woningplan/woonkamer basis.swf", empty_string
, &size
, URL_ESCAPE_AS_UTF8
);
904 ok(ret
== E_NOTIMPL
|| broken(ret
== E_POINTER
), /* < Win7/Win2k8 */
905 "got %x, expected %x\n", ret
, E_NOTIMPL
);
906 ok(size
== 1 || broken(size
== 34), /* < Win7/Win2k8 */
907 "got %d, expected %d\n", size
, 1);
908 ok(empty_string
[0] == 127, "String has changed, empty_string[0] = %d\n", empty_string
[0]);
910 for(i
=0; i
<sizeof(TEST_ESCAPE
)/sizeof(TEST_ESCAPE
[0]); i
++) {
911 CHAR ret_url
[INTERNET_MAX_URL_LENGTH
];
913 size
= INTERNET_MAX_URL_LENGTH
;
914 ret
= pUrlEscapeA(TEST_ESCAPE
[i
].url
, ret_url
, &size
, TEST_ESCAPE
[i
].flags
);
915 ok(ret
== TEST_ESCAPE
[i
].expectret
, "UrlEscapeA returned 0x%08x instead of 0x%08x for \"%s\"\n",
916 ret
, TEST_ESCAPE
[i
].expectret
, TEST_ESCAPE
[i
].url
);
917 ok(!strcmp(ret_url
, TEST_ESCAPE
[i
].expecturl
), "Expected \"%s\", but got \"%s\" for \"%s\"\n",
918 TEST_ESCAPE
[i
].expecturl
, ret_url
, TEST_ESCAPE
[i
].url
);
922 static void test_UrlEscapeW(void)
924 static const WCHAR naW
[] = {'f','t','p',31,255,250,0x2122,'e','n','d','/',0};
925 static const WCHAR naescapedW
[] = {'f','t','p','%','1','F','%','F','F','%','F','A',0x2122,'e','n','d','/',0};
926 static const WCHAR out
[] = {'f','o','o','%','2','0','b','a','r',0};
927 WCHAR overwrite
[] = {'f','o','o',' ','b','a','r',0,0,0};
928 WCHAR ret_urlW
[INTERNET_MAX_URL_LENGTH
];
935 win_skip("UrlEscapeW not found\n");
939 size
= sizeof(overwrite
)/sizeof(WCHAR
);
940 ret
= pUrlEscapeW(overwrite
, overwrite
, &size
, URL_ESCAPE_SPACES_ONLY
);
941 ok(ret
== S_OK
, "got %x, expected S_OK\n", ret
);
942 ok(size
== 9, "got %d, expected 9\n", size
);
943 ok(!lstrcmpW(overwrite
, out
), "got %s, expected %s\n", wine_dbgstr_w(overwrite
), wine_dbgstr_w(out
));
947 ret
= pUrlEscapeW(overwrite
, &wc
, &size
, URL_ESCAPE_SPACES_ONLY
);
948 ok(ret
== E_POINTER
, "got %x, expected %x\n", ret
, E_POINTER
);
949 ok(size
== 10, "got %d, expected 10\n", size
);
950 ok(wc
== 127, "String has changed, wc = %d\n", wc
);
952 /* non-ASCII range */
953 size
= sizeof(ret_urlW
)/sizeof(WCHAR
);
954 ret
= pUrlEscapeW(naW
, ret_urlW
, &size
, 0);
955 ok(ret
== S_OK
, "got %x, expected S_OK\n", ret
);
956 ok(!lstrcmpW(naescapedW
, ret_urlW
), "got %s, expected %s\n", wine_dbgstr_w(ret_urlW
), wine_dbgstr_w(naescapedW
));
958 for (i
= 0; i
< sizeof(TEST_ESCAPE
)/sizeof(TEST_ESCAPE
[0]); i
++) {
960 WCHAR
*urlW
, *expected_urlW
;
962 size
= INTERNET_MAX_URL_LENGTH
;
963 urlW
= GetWideString(TEST_ESCAPE
[i
].url
);
964 expected_urlW
= GetWideString(TEST_ESCAPE
[i
].expecturl
);
965 ret
= pUrlEscapeW(urlW
, ret_urlW
, &size
, TEST_ESCAPE
[i
].flags
);
966 ok(ret
== TEST_ESCAPE
[i
].expectret
, "UrlEscapeW returned 0x%08x instead of 0x%08x for %s\n",
967 ret
, TEST_ESCAPE
[i
].expectret
, wine_dbgstr_w(urlW
));
968 ok(!lstrcmpW(ret_urlW
, expected_urlW
), "Expected %s, but got %s for %s flags %08x\n",
969 wine_dbgstr_w(expected_urlW
), wine_dbgstr_w(ret_urlW
), wine_dbgstr_w(urlW
), TEST_ESCAPE
[i
].flags
);
970 FreeWideString(urlW
);
971 FreeWideString(expected_urlW
);
974 for(i
=0; i
<sizeof(TEST_ESCAPEW
)/sizeof(TEST_ESCAPEW
[0]); i
++) {
975 WCHAR ret_url
[INTERNET_MAX_URL_LENGTH
];
977 size
= INTERNET_MAX_URL_LENGTH
;
978 ret
= pUrlEscapeW(TEST_ESCAPEW
[i
].url
, ret_url
, &size
, TEST_ESCAPEW
[i
].flags
);
979 ok(ret
== TEST_ESCAPEW
[i
].expectret
, "UrlEscapeW returned 0x%08x instead of 0x%08x for \"%s\"\n",
980 ret
, TEST_ESCAPEW
[i
].expectret
, wine_dbgstr_w(TEST_ESCAPEW
[i
].url
));
981 ok(!lstrcmpW(ret_url
, TEST_ESCAPEW
[i
].expecturl
) ||
982 broken(!lstrcmpW(ret_url
, TEST_ESCAPEW
[i
].vistaurl
)) ||
983 broken(!lstrcmpW(ret_url
, TEST_ESCAPEW
[i
].win7url
)),
984 "Expected \"%s\" or \"%s\" or \"%s\", but got \"%s\" for \"%s\"\n",
985 wine_dbgstr_w(TEST_ESCAPEW
[i
].expecturl
), wine_dbgstr_w(TEST_ESCAPEW
[i
].vistaurl
),
986 wine_dbgstr_w(TEST_ESCAPEW
[i
].win7url
), wine_dbgstr_w(ret_url
), wine_dbgstr_w(TEST_ESCAPEW
[i
].url
));
990 /* ########################### */
992 static void test_UrlCanonicalizeA(void)
995 CHAR szReturnUrl
[4*INTERNET_MAX_URL_LENGTH
];
996 CHAR longurl
[4*INTERNET_MAX_URL_LENGTH
];
1001 if (!pUrlCanonicalizeA
) {
1002 win_skip("UrlCanonicalizeA not found\n");
1006 urllen
= lstrlenA(winehqA
);
1008 /* buffer has no space for the result */
1010 memset(szReturnUrl
, '#', urllen
+4);
1011 szReturnUrl
[urllen
+4] = '\0';
1012 SetLastError(0xdeadbeef);
1013 hr
= pUrlCanonicalizeA(winehqA
, szReturnUrl
, &dwSize
, URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
);
1014 ok( (hr
== E_POINTER
) && (dwSize
== (urllen
+ 1)),
1015 "got 0x%x with %u and size %u for '%s' and %u (expected 'E_POINTER' and size %u)\n",
1016 hr
, GetLastError(), dwSize
, szReturnUrl
, lstrlenA(szReturnUrl
), urllen
+1);
1018 /* buffer has no space for the terminating '\0' */
1020 memset(szReturnUrl
, '#', urllen
+4);
1021 szReturnUrl
[urllen
+4] = '\0';
1022 SetLastError(0xdeadbeef);
1023 hr
= pUrlCanonicalizeA(winehqA
, szReturnUrl
, &dwSize
, URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
);
1024 ok( (hr
== E_POINTER
) && (dwSize
== (urllen
+ 1)),
1025 "got 0x%x with %u and size %u for '%s' and %u (expected 'E_POINTER' and size %u)\n",
1026 hr
, GetLastError(), dwSize
, szReturnUrl
, lstrlenA(szReturnUrl
), urllen
+1);
1028 /* buffer has the required size */
1030 memset(szReturnUrl
, '#', urllen
+4);
1031 szReturnUrl
[urllen
+4] = '\0';
1032 SetLastError(0xdeadbeef);
1033 hr
= pUrlCanonicalizeA(winehqA
, szReturnUrl
, &dwSize
, URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
);
1034 ok( (hr
== S_OK
) && (dwSize
== urllen
),
1035 "got 0x%x with %u and size %u for '%s' and %u (expected 'S_OK' and size %u)\n",
1036 hr
, GetLastError(), dwSize
, szReturnUrl
, lstrlenA(szReturnUrl
), urllen
);
1038 /* buffer is larger as the required size */
1040 memset(szReturnUrl
, '#', urllen
+4);
1041 szReturnUrl
[urllen
+4] = '\0';
1042 SetLastError(0xdeadbeef);
1043 hr
= pUrlCanonicalizeA(winehqA
, szReturnUrl
, &dwSize
, URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
);
1044 ok( (hr
== S_OK
) && (dwSize
== urllen
),
1045 "got 0x%x with %u and size %u for '%s' and %u (expected 'S_OK' and size %u)\n",
1046 hr
, GetLastError(), dwSize
, szReturnUrl
, lstrlenA(szReturnUrl
), urllen
);
1048 /* length is set to 0 */
1050 memset(szReturnUrl
, '#', urllen
+4);
1051 szReturnUrl
[urllen
+4] = '\0';
1052 SetLastError(0xdeadbeef);
1053 hr
= pUrlCanonicalizeA(winehqA
, szReturnUrl
, &dwSize
, URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
);
1054 ok( (hr
== E_INVALIDARG
) && (dwSize
== 0),
1055 "got 0x%x with %u and size %u for '%s' and %u (expected 'E_INVALIDARG' and size %u)\n",
1056 hr
, GetLastError(), dwSize
, szReturnUrl
, lstrlenA(szReturnUrl
), 0);
1058 /* url length > INTERNET_MAX_URL_SIZE */
1059 dwSize
=sizeof(szReturnUrl
);
1060 memset(longurl
, 'a', sizeof(longurl
));
1061 memcpy(longurl
, winehqA
, sizeof(winehqA
)-1);
1062 longurl
[sizeof(longurl
)-1] = '\0';
1063 hr
= pUrlCanonicalizeA(longurl
, szReturnUrl
, &dwSize
, URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
);
1064 ok(hr
== S_OK
, "hr = %x\n", hr
);
1066 test_url_canonicalize(-1, "", 0, S_OK
, S_FALSE
/* Vista/win2k8 */, "", FALSE
);
1068 /* test url-modification */
1069 for(i
=0; i
<sizeof(TEST_CANONICALIZE
)/sizeof(TEST_CANONICALIZE
[0]); i
++) {
1070 test_url_canonicalize(i
, TEST_CANONICALIZE
[i
].url
, TEST_CANONICALIZE
[i
].flags
,
1071 TEST_CANONICALIZE
[i
].expectret
, TEST_CANONICALIZE
[i
].expectret
, TEST_CANONICALIZE
[i
].expecturl
,
1072 TEST_CANONICALIZE
[i
].todo
);
1076 /* ########################### */
1078 static void test_UrlCanonicalizeW(void)
1080 WCHAR szReturnUrl
[INTERNET_MAX_URL_LENGTH
];
1087 if (!pUrlCanonicalizeW
) {
1088 win_skip("UrlCanonicalizeW not found\n");
1091 urllen
= lstrlenW(winehqW
);
1093 /* buffer has no space for the result */
1094 dwSize
= (urllen
-1);
1095 memset(szReturnUrl
, '#', (urllen
+4) * sizeof(WCHAR
));
1096 szReturnUrl
[urllen
+4] = '\0';
1097 SetLastError(0xdeadbeef);
1098 hr
= pUrlCanonicalizeW(winehqW
, szReturnUrl
, &dwSize
, URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
);
1099 ok( (hr
== E_POINTER
) && (dwSize
== (urllen
+ 1)),
1100 "got 0x%x with %u and size %u for %u (expected 'E_POINTER' and size %u)\n",
1101 hr
, GetLastError(), dwSize
, lstrlenW(szReturnUrl
), urllen
+1);
1104 /* buffer has no space for the terminating '\0' */
1106 memset(szReturnUrl
, '#', (urllen
+4) * sizeof(WCHAR
));
1107 szReturnUrl
[urllen
+4] = '\0';
1108 SetLastError(0xdeadbeef);
1109 hr
= pUrlCanonicalizeW(winehqW
, szReturnUrl
, &dwSize
, URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
);
1110 ok( (hr
== E_POINTER
) && (dwSize
== (urllen
+ 1)),
1111 "got 0x%x with %u and size %u for %u (expected 'E_POINTER' and size %u)\n",
1112 hr
, GetLastError(), dwSize
, lstrlenW(szReturnUrl
), urllen
+1);
1114 /* buffer has the required size */
1116 memset(szReturnUrl
, '#', (urllen
+4) * sizeof(WCHAR
));
1117 szReturnUrl
[urllen
+4] = '\0';
1118 SetLastError(0xdeadbeef);
1119 hr
= pUrlCanonicalizeW(winehqW
, szReturnUrl
, &dwSize
, URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
);
1120 ok( (hr
== S_OK
) && (dwSize
== urllen
),
1121 "got 0x%x with %u and size %u for %u (expected 'S_OK' and size %u)\n",
1122 hr
, GetLastError(), dwSize
, lstrlenW(szReturnUrl
), urllen
);
1124 /* buffer is larger as the required size */
1125 dwSize
= (urllen
+2);
1126 memset(szReturnUrl
, '#', (urllen
+4) * sizeof(WCHAR
));
1127 szReturnUrl
[urllen
+4] = '\0';
1128 SetLastError(0xdeadbeef);
1129 hr
= pUrlCanonicalizeW(winehqW
, szReturnUrl
, &dwSize
, URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
);
1130 ok( (hr
== S_OK
) && (dwSize
== urllen
),
1131 "got 0x%x with %u and size %u for %u (expected 'S_OK' and size %u)\n",
1132 hr
, GetLastError(), dwSize
, lstrlenW(szReturnUrl
), urllen
);
1134 /* check that the characters 1..32 are chopped from the end of the string */
1135 for (i
= 1; i
< 65536; i
++)
1141 MultiByteToWideChar(CP_ACP
, 0, "http://www.winehq.org/X", -1, szUrl
, sizeof(szUrl
)/sizeof(szUrl
[0]));
1142 pos
= lstrlenW(szUrl
) - 1;
1144 urllen
= INTERNET_MAX_URL_LENGTH
;
1145 pUrlCanonicalizeW(szUrl
, szReturnUrl
, &urllen
, 0);
1146 choped
= lstrlenW(szReturnUrl
) < lstrlenW(szUrl
);
1147 ok(choped
== (i
<= 32), "Incorrect char chopping for char %d\n", i
);
1151 /* ########################### */
1153 static void test_url_combine(const char *szUrl1
, const char *szUrl2
, DWORD dwFlags
, HRESULT dwExpectReturn
, const char *szExpectUrl
)
1156 CHAR szReturnUrl
[INTERNET_MAX_URL_LENGTH
];
1157 WCHAR wszReturnUrl
[INTERNET_MAX_URL_LENGTH
];
1158 LPWSTR wszUrl1
, wszUrl2
, wszExpectUrl
, wszConvertedUrl
;
1161 DWORD dwExpectLen
= lstrlenA(szExpectUrl
);
1163 if (!pUrlCombineA
) {
1164 win_skip("UrlCombineA not found\n");
1168 wszUrl1
= GetWideString(szUrl1
);
1169 wszUrl2
= GetWideString(szUrl2
);
1170 wszExpectUrl
= GetWideString(szExpectUrl
);
1172 hr
= pUrlCombineA(szUrl1
, szUrl2
, NULL
, NULL
, dwFlags
);
1173 ok(hr
== E_INVALIDARG
, "UrlCombineA returned 0x%08x, expected 0x%08x\n", hr
, E_INVALIDARG
);
1176 hr
= pUrlCombineA(szUrl1
, szUrl2
, NULL
, &dwSize
, dwFlags
);
1177 ok(hr
== E_POINTER
, "Checking length of string, return was 0x%08x, expected 0x%08x\n", hr
, E_POINTER
);
1178 ok(dwSize
== dwExpectLen
+1, "Got length %d, expected %d\n", dwSize
, dwExpectLen
+1);
1181 hr
= pUrlCombineA(szUrl1
, szUrl2
, szReturnUrl
, &dwSize
, dwFlags
);
1182 ok(hr
== E_POINTER
, "UrlCombineA returned 0x%08x, expected 0x%08x\n", hr
, E_POINTER
);
1183 ok(dwSize
== dwExpectLen
+1, "Got length %d, expected %d\n", dwSize
, dwExpectLen
+1);
1185 hr
= pUrlCombineA(szUrl1
, szUrl2
, szReturnUrl
, &dwSize
, dwFlags
);
1186 ok(hr
== dwExpectReturn
, "UrlCombineA returned 0x%08x, expected 0x%08x\n", hr
, dwExpectReturn
);
1187 ok(dwSize
== dwExpectLen
, "Got length %d, expected %d\n", dwSize
, dwExpectLen
);
1189 ok(strcmp(szReturnUrl
,szExpectUrl
)==0, "Expected %s, but got %s\n", szExpectUrl
, szReturnUrl
);
1194 hr
= pUrlCombineW(wszUrl1
, wszUrl2
, NULL
, &dwSize
, dwFlags
);
1195 ok(hr
== E_POINTER
, "Checking length of string, return was 0x%08x, expected 0x%08x\n", hr
, E_POINTER
);
1196 ok(dwSize
== dwExpectLen
+1, "Got length %d, expected %d\n", dwSize
, dwExpectLen
+1);
1199 hr
= pUrlCombineW(wszUrl1
, wszUrl2
, wszReturnUrl
, &dwSize
, dwFlags
);
1200 ok(hr
== E_POINTER
, "UrlCombineW returned 0x%08x, expected 0x%08x\n", hr
, E_POINTER
);
1201 ok(dwSize
== dwExpectLen
+1, "Got length %d, expected %d\n", dwSize
, dwExpectLen
+1);
1203 hr
= pUrlCombineW(wszUrl1
, wszUrl2
, wszReturnUrl
, &dwSize
, dwFlags
);
1204 ok(hr
== dwExpectReturn
, "UrlCombineW returned 0x%08x, expected 0x%08x\n", hr
, dwExpectReturn
);
1205 ok(dwSize
== dwExpectLen
, "Got length %d, expected %d\n", dwSize
, dwExpectLen
);
1207 wszConvertedUrl
= GetWideString(szReturnUrl
);
1208 ok(lstrcmpW(wszReturnUrl
, wszConvertedUrl
)==0, "Strings didn't match between ascii and unicode UrlCombine!\n");
1209 FreeWideString(wszConvertedUrl
);
1213 FreeWideString(wszUrl1
);
1214 FreeWideString(wszUrl2
);
1215 FreeWideString(wszExpectUrl
);
1218 /* ########################### */
1220 static void test_UrlCombine(void)
1223 for(i
=0; i
<sizeof(TEST_COMBINE
)/sizeof(TEST_COMBINE
[0]); i
++) {
1224 test_url_combine(TEST_COMBINE
[i
].url1
, TEST_COMBINE
[i
].url2
, TEST_COMBINE
[i
].flags
,
1225 TEST_COMBINE
[i
].expectret
, TEST_COMBINE
[i
].expecturl
);
1229 /* ########################### */
1231 static void test_UrlCreateFromPath(void)
1234 char ret_url
[INTERNET_MAX_URL_LENGTH
];
1236 WCHAR ret_urlW
[INTERNET_MAX_URL_LENGTH
];
1237 WCHAR
*pathW
, *urlW
;
1239 if (!pUrlCreateFromPathA
) {
1240 win_skip("UrlCreateFromPathA not found\n");
1244 for(i
= 0; i
< sizeof(TEST_URLFROMPATH
) / sizeof(TEST_URLFROMPATH
[0]); i
++) {
1245 len
= INTERNET_MAX_URL_LENGTH
;
1246 ret
= pUrlCreateFromPathA(TEST_URLFROMPATH
[i
].path
, ret_url
, &len
, 0);
1247 ok(ret
== TEST_URLFROMPATH
[i
].ret
, "ret %08x from path %s\n", ret
, TEST_URLFROMPATH
[i
].path
);
1248 ok(!lstrcmpiA(ret_url
, TEST_URLFROMPATH
[i
].url
), "url %s from path %s\n", ret_url
, TEST_URLFROMPATH
[i
].path
);
1249 ok(len
== strlen(ret_url
), "ret len %d from path %s\n", len
, TEST_URLFROMPATH
[i
].path
);
1251 if (pUrlCreateFromPathW
) {
1252 len
= INTERNET_MAX_URL_LENGTH
;
1253 pathW
= GetWideString(TEST_URLFROMPATH
[i
].path
);
1254 urlW
= GetWideString(TEST_URLFROMPATH
[i
].url
);
1255 ret
= pUrlCreateFromPathW(pathW
, ret_urlW
, &len
, 0);
1256 WideCharToMultiByte(CP_ACP
, 0, ret_urlW
, -1, ret_url
, sizeof(ret_url
),0,0);
1257 ok(ret
== TEST_URLFROMPATH
[i
].ret
, "ret %08x from path L\"%s\", expected %08x\n",
1258 ret
, TEST_URLFROMPATH
[i
].path
, TEST_URLFROMPATH
[i
].ret
);
1259 ok(!lstrcmpiW(ret_urlW
, urlW
), "got %s expected %s from path L\"%s\"\n",
1260 ret_url
, TEST_URLFROMPATH
[i
].url
, TEST_URLFROMPATH
[i
].path
);
1261 ok(len
== lstrlenW(ret_urlW
), "ret len %d from path L\"%s\"\n", len
, TEST_URLFROMPATH
[i
].path
);
1262 FreeWideString(urlW
);
1263 FreeWideString(pathW
);
1268 /* ########################### */
1270 static void test_UrlIs_null(DWORD flag
)
1273 ret
= pUrlIsA(NULL
, flag
);
1274 ok(ret
== FALSE
, "pUrlIsA(NULL, %d) failed\n", flag
);
1275 ret
= pUrlIsW(NULL
, flag
);
1276 ok(ret
== FALSE
, "pUrlIsW(NULL, %d) failed\n", flag
);
1279 static void test_UrlIs(void)
1286 win_skip("UrlIsA not found\n");
1290 test_UrlIs_null(URLIS_APPLIABLE
);
1291 test_UrlIs_null(URLIS_DIRECTORY
);
1292 test_UrlIs_null(URLIS_FILEURL
);
1293 test_UrlIs_null(URLIS_HASQUERY
);
1294 test_UrlIs_null(URLIS_NOHISTORY
);
1295 test_UrlIs_null(URLIS_OPAQUE
);
1296 test_UrlIs_null(URLIS_URL
);
1298 for(i
= 0; i
< sizeof(TEST_PATH_IS_URL
) / sizeof(TEST_PATH_IS_URL
[0]); i
++) {
1299 MultiByteToWideChar(CP_ACP
, 0, TEST_PATH_IS_URL
[i
].path
, -1, wurl
, sizeof(wurl
)/sizeof(*wurl
));
1301 ret
= pUrlIsA( TEST_PATH_IS_URL
[i
].path
, URLIS_URL
);
1302 ok( ret
== TEST_PATH_IS_URL
[i
].expect
,
1303 "returned %d from path %s, expected %d\n", ret
, TEST_PATH_IS_URL
[i
].path
,
1304 TEST_PATH_IS_URL
[i
].expect
);
1307 ret
= pUrlIsW( wurl
, URLIS_URL
);
1308 ok( ret
== TEST_PATH_IS_URL
[i
].expect
,
1309 "returned %d from path (UrlIsW) %s, expected %d\n", ret
,
1310 TEST_PATH_IS_URL
[i
].path
, TEST_PATH_IS_URL
[i
].expect
);
1313 for(i
= 0; i
< sizeof(TEST_URLIS_ATTRIBS
) / sizeof(TEST_URLIS_ATTRIBS
[0]); i
++) {
1314 MultiByteToWideChar(CP_ACP
, 0, TEST_URLIS_ATTRIBS
[i
].url
, -1, wurl
, sizeof(wurl
)/sizeof(*wurl
));
1316 ret
= pUrlIsA( TEST_URLIS_ATTRIBS
[i
].url
, URLIS_OPAQUE
);
1317 ok( ret
== TEST_URLIS_ATTRIBS
[i
].expectOpaque
,
1318 "returned %d for URLIS_OPAQUE, url \"%s\", expected %d\n", ret
, TEST_URLIS_ATTRIBS
[i
].url
,
1319 TEST_URLIS_ATTRIBS
[i
].expectOpaque
);
1320 ret
= pUrlIsA( TEST_URLIS_ATTRIBS
[i
].url
, URLIS_FILEURL
);
1321 ok( ret
== TEST_URLIS_ATTRIBS
[i
].expectFile
,
1322 "returned %d for URLIS_FILEURL, url \"%s\", expected %d\n", ret
, TEST_URLIS_ATTRIBS
[i
].url
,
1323 TEST_URLIS_ATTRIBS
[i
].expectFile
);
1326 ret
= pUrlIsW( wurl
, URLIS_OPAQUE
);
1327 ok( ret
== TEST_URLIS_ATTRIBS
[i
].expectOpaque
,
1328 "returned %d for URLIS_OPAQUE (UrlIsW), url \"%s\", expected %d\n",
1329 ret
, TEST_URLIS_ATTRIBS
[i
].url
, TEST_URLIS_ATTRIBS
[i
].expectOpaque
);
1330 ret
= pUrlIsW( wurl
, URLIS_FILEURL
);
1331 ok( ret
== TEST_URLIS_ATTRIBS
[i
].expectFile
,
1332 "returned %d for URLIS_FILEURL (UrlIsW), url \"%s\", expected %d\n",
1333 ret
, TEST_URLIS_ATTRIBS
[i
].url
, TEST_URLIS_ATTRIBS
[i
].expectFile
);
1338 /* ########################### */
1340 static void test_UrlUnescape(void)
1342 CHAR szReturnUrl
[INTERNET_MAX_URL_LENGTH
];
1343 WCHAR ret_urlW
[INTERNET_MAX_URL_LENGTH
];
1344 WCHAR
*urlW
, *expected_urlW
;
1347 static char inplace
[] = "file:///C:/Program%20Files";
1348 static char another_inplace
[] = "file:///C:/Program%20Files";
1349 static const char expected
[] = "file:///C:/Program Files";
1350 static WCHAR inplaceW
[] = {'f','i','l','e',':','/','/','/','C',':','/','P','r','o','g','r','a','m',' ','F','i','l','e','s',0};
1351 static WCHAR another_inplaceW
[] ={'f','i','l','e',':','/','/','/',
1352 'C',':','/','P','r','o','g','r','a','m','%','2','0','F','i','l','e','s',0};
1355 if (!pUrlUnescapeA
) {
1356 win_skip("UrlUnescapeA not found\n");
1359 for(i
=0; i
<sizeof(TEST_URL_UNESCAPE
)/sizeof(TEST_URL_UNESCAPE
[0]); i
++) {
1360 dwEscaped
=INTERNET_MAX_URL_LENGTH
;
1361 res
= pUrlUnescapeA(TEST_URL_UNESCAPE
[i
].url
, szReturnUrl
, &dwEscaped
, 0);
1363 "UrlUnescapeA returned 0x%x (expected S_OK) for \"%s\"\n",
1364 res
, TEST_URL_UNESCAPE
[i
].url
);
1365 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
);
1367 ZeroMemory(szReturnUrl
, sizeof(szReturnUrl
));
1368 /* if we set the buffer pointer to NULL here, UrlUnescape fails and the string is not converted */
1369 res
= pUrlUnescapeA(TEST_URL_UNESCAPE
[i
].url
, szReturnUrl
, NULL
, 0);
1370 ok(res
== E_INVALIDARG
,
1371 "UrlUnescapeA returned 0x%x (expected E_INVALIDARG) for \"%s\"\n",
1372 res
, TEST_URL_UNESCAPE
[i
].url
);
1373 ok(strcmp(szReturnUrl
,"")==0, "Expected empty string\n");
1375 if (pUrlUnescapeW
) {
1376 dwEscaped
= INTERNET_MAX_URL_LENGTH
;
1377 urlW
= GetWideString(TEST_URL_UNESCAPE
[i
].url
);
1378 expected_urlW
= GetWideString(TEST_URL_UNESCAPE
[i
].expect
);
1379 res
= pUrlUnescapeW(urlW
, ret_urlW
, &dwEscaped
, 0);
1381 "UrlUnescapeW returned 0x%x (expected S_OK) for \"%s\"\n",
1382 res
, TEST_URL_UNESCAPE
[i
].url
);
1384 WideCharToMultiByte(CP_ACP
,0,ret_urlW
,-1,szReturnUrl
,INTERNET_MAX_URL_LENGTH
,0,0);
1385 ok(lstrcmpW(ret_urlW
, expected_urlW
)==0,
1386 "Expected \"%s\", but got \"%s\" from \"%s\" flags %08lx\n",
1387 TEST_URL_UNESCAPE
[i
].expect
, szReturnUrl
, TEST_URL_UNESCAPE
[i
].url
, 0L);
1388 FreeWideString(urlW
);
1389 FreeWideString(expected_urlW
);
1393 dwEscaped
= sizeof(inplace
);
1394 res
= pUrlUnescapeA(inplace
, NULL
, &dwEscaped
, URL_UNESCAPE_INPLACE
);
1395 ok(res
== S_OK
, "UrlUnescapeA returned 0x%x (expected S_OK)\n", res
);
1396 ok(!strcmp(inplace
, expected
), "got %s expected %s\n", inplace
, expected
);
1397 ok(dwEscaped
== 27, "got %d expected 27\n", dwEscaped
);
1399 /* if we set the buffer pointer to NULL, the string apparently still gets converted (Google Lively does this) */
1400 res
= pUrlUnescapeA(another_inplace
, NULL
, NULL
, URL_UNESCAPE_INPLACE
);
1401 ok(res
== S_OK
, "UrlUnescapeA returned 0x%x (expected S_OK)\n", res
);
1402 ok(!strcmp(another_inplace
, expected
), "got %s expected %s\n", another_inplace
, expected
);
1404 if (pUrlUnescapeW
) {
1405 dwEscaped
= sizeof(inplaceW
);
1406 res
= pUrlUnescapeW(inplaceW
, NULL
, &dwEscaped
, URL_UNESCAPE_INPLACE
);
1407 ok(res
== S_OK
, "UrlUnescapeW returned 0x%x (expected S_OK)\n", res
);
1408 ok(dwEscaped
== 50, "got %d expected 50\n", dwEscaped
);
1410 /* if we set the buffer pointer to NULL, the string apparently still gets converted (Google Lively does this) */
1411 res
= pUrlUnescapeW(another_inplaceW
, NULL
, NULL
, URL_UNESCAPE_INPLACE
);
1412 ok(res
== S_OK
, "UrlUnescapeW returned 0x%x (expected S_OK)\n", res
);
1414 ok(lstrlenW(another_inplaceW
) == 24, "got %d expected 24\n", lstrlenW(another_inplaceW
));
1418 static const struct parse_url_test_t
{
1423 } parse_url_tests
[] = {
1424 {"http://www.winehq.org/",S_OK
,4,URL_SCHEME_HTTP
},
1425 {"https://www.winehq.org/",S_OK
,5,URL_SCHEME_HTTPS
},
1426 {"ftp://www.winehq.org/",S_OK
,3,URL_SCHEME_FTP
},
1427 {"test.txt?test=c:/dir",URL_E_INVALID_SYNTAX
},
1428 {"test.txt",URL_E_INVALID_SYNTAX
},
1429 {"xxx://www.winehq.org/",S_OK
,3,URL_SCHEME_UNKNOWN
},
1430 {"1xx://www.winehq.org/",S_OK
,3,URL_SCHEME_UNKNOWN
},
1431 {"-xx://www.winehq.org/",S_OK
,3,URL_SCHEME_UNKNOWN
},
1432 {"xx0://www.winehq.org/",S_OK
,3,URL_SCHEME_UNKNOWN
},
1433 {"x://www.winehq.org/",URL_E_INVALID_SYNTAX
},
1434 {"xx$://www.winehq.org/",URL_E_INVALID_SYNTAX
},
1435 {"htt?p://www.winehq.org/",URL_E_INVALID_SYNTAX
},
1436 {"ab-://www.winehq.org/",S_OK
,3,URL_SCHEME_UNKNOWN
},
1437 {" http://www.winehq.org/",URL_E_INVALID_SYNTAX
},
1440 static void test_ParseURL(void)
1442 const struct parse_url_test_t
*test
;
1443 WCHAR url
[INTERNET_MAX_URL_LENGTH
];
1448 for(test
= parse_url_tests
; test
< parse_url_tests
+ sizeof(parse_url_tests
)/sizeof(*parse_url_tests
); test
++) {
1449 memset(&parseda
, 0xd0, sizeof(parseda
));
1450 parseda
.cbSize
= sizeof(parseda
);
1451 hres
= pParseURLA(test
->url
, &parseda
);
1452 ok(hres
== test
->hres
, "ParseURL failed: %08x, expected %08x\n", hres
, test
->hres
);
1454 ok(parseda
.pszProtocol
== test
->url
, "parseda.pszProtocol = %s, expected %s\n",
1455 parseda
.pszProtocol
, test
->url
);
1456 ok(parseda
.cchProtocol
== test
->protocol_len
, "parseda.cchProtocol = %d, expected %d\n",
1457 parseda
.cchProtocol
, test
->protocol_len
);
1458 ok(parseda
.pszSuffix
== test
->url
+test
->protocol_len
+1, "parseda.pszSuffix = %s, expected %s\n",
1459 parseda
.pszSuffix
, test
->url
+test
->protocol_len
+1);
1460 ok(parseda
.cchSuffix
== strlen(test
->url
+test
->protocol_len
+1),
1461 "parseda.pszSuffix = %d, expected %d\n",
1462 parseda
.cchSuffix
, lstrlenA(test
->url
+test
->protocol_len
+1));
1463 ok(parseda
.nScheme
== test
->scheme
, "parseda.nScheme = %d, expected %d\n",
1464 parseda
.nScheme
, test
->scheme
);
1466 ok(!parseda
.pszProtocol
, "parseda.pszProtocol = %p\n", parseda
.pszProtocol
);
1467 ok(parseda
.nScheme
== 0xd0d0d0d0, "nScheme = %d\n", parseda
.nScheme
);
1470 MultiByteToWideChar(CP_ACP
, 0, test
->url
, -1, url
, sizeof(url
)/sizeof(WCHAR
));
1472 memset(&parsedw
, 0xd0, sizeof(parsedw
));
1473 parsedw
.cbSize
= sizeof(parsedw
);
1474 hres
= pParseURLW(url
, &parsedw
);
1475 ok(hres
== test
->hres
, "ParseURL failed: %08x, expected %08x\n", hres
, test
->hres
);
1477 ok(parsedw
.pszProtocol
== url
, "parsedw.pszProtocol = %s, expected %s\n",
1478 wine_dbgstr_w(parsedw
.pszProtocol
), wine_dbgstr_w(url
));
1479 ok(parsedw
.cchProtocol
== test
->protocol_len
, "parsedw.cchProtocol = %d, expected %d\n",
1480 parsedw
.cchProtocol
, test
->protocol_len
);
1481 ok(parsedw
.pszSuffix
== url
+test
->protocol_len
+1, "parsedw.pszSuffix = %s, expected %s\n",
1482 wine_dbgstr_w(parsedw
.pszSuffix
), wine_dbgstr_w(url
+test
->protocol_len
+1));
1483 ok(parsedw
.cchSuffix
== strlen(test
->url
+test
->protocol_len
+1),
1484 "parsedw.pszSuffix = %d, expected %d\n",
1485 parsedw
.cchSuffix
, lstrlenA(test
->url
+test
->protocol_len
+1));
1486 ok(parsedw
.nScheme
== test
->scheme
, "parsedw.nScheme = %d, expected %d\n",
1487 parsedw
.nScheme
, test
->scheme
);
1489 ok(!parsedw
.pszProtocol
, "parsedw.pszProtocol = %p\n", parseda
.pszProtocol
);
1490 ok(parsedw
.nScheme
== 0xd0d0d0d0, "nScheme = %d\n", parsedw
.nScheme
);
1495 static void test_HashData(void)
1498 BYTE input
[16] = {0x51, 0x33, 0x4F, 0xA7, 0x45, 0x15, 0xF0, 0x52, 0x90,
1499 0x2B, 0xE7, 0xF5, 0xFD, 0xE1, 0xA6, 0xA7};
1501 static const BYTE expected
[] = {0x54, 0x9C, 0x92, 0x55, 0xCD, 0x82, 0xFF,
1502 0xA1, 0x8E, 0x0F, 0xCF, 0x93, 0x14, 0xAA,
1504 static const BYTE expected2
[] = {0x54, 0x9C, 0x92, 0x55, 0xCD, 0x82, 0xFF,
1505 0xA1, 0x8E, 0x0F, 0xCF, 0x93, 0x14, 0xAA,
1506 0xE3, 0x2D, 0x47, 0xFC, 0x80, 0xB8, 0xD0,
1507 0x49, 0xE6, 0x13, 0x2A, 0x30, 0x51, 0x8D,
1508 0xF9, 0x4B, 0x07, 0xA6};
1509 static const BYTE expected3
[] = {0x2B, 0xDC, 0x9A, 0x1B, 0xF0, 0x5A, 0xF9,
1510 0xC6, 0xBE, 0x94, 0x6D, 0xF3, 0x33, 0xC1,
1514 /* Test hashing with identically sized input/output buffers. */
1515 res
= pHashData(input
, 16, output
, 16);
1516 ok(res
== S_OK
, "Expected HashData to return S_OK, got 0x%08x\n", res
);
1518 ok(!memcmp(output
, expected
, sizeof(expected
)),
1519 "Output buffer did not match expected contents\n");
1521 /* Test hashing with larger output buffer. */
1522 res
= pHashData(input
, 16, output
, 32);
1523 ok(res
== S_OK
, "Expected HashData to return S_OK, got 0x%08x\n", res
);
1525 ok(!memcmp(output
, expected2
, sizeof(expected2
)),
1526 "Output buffer did not match expected contents\n");
1528 /* Test hashing with smaller input buffer. */
1529 res
= pHashData(input
, 8, output
, 16);
1530 ok(res
== S_OK
, "Expected HashData to return S_OK, got 0x%08x\n", res
);
1532 ok(!memcmp(output
, expected3
, sizeof(expected3
)),
1533 "Output buffer did not match expected contents\n");
1535 /* Test passing NULL pointers for input/output parameters. */
1536 res
= pHashData(NULL
, 0, NULL
, 0);
1537 ok(res
== E_INVALIDARG
|| broken(res
== S_OK
), /* Windows 2000 */
1538 "Expected HashData to return E_INVALIDARG, got 0x%08x\n", res
);
1540 res
= pHashData(input
, 0, NULL
, 0);
1541 ok(res
== E_INVALIDARG
|| broken(res
== S_OK
), /* Windows 2000 */
1542 "Expected HashData to return E_INVALIDARG, got 0x%08x\n", res
);
1544 res
= pHashData(NULL
, 0, output
, 0);
1545 ok(res
== E_INVALIDARG
|| broken(res
== S_OK
), /* Windows 2000 */
1546 "Expected HashData to return E_INVALIDARG, got 0x%08x\n", res
);
1548 /* Test passing valid pointers with sizes of zero. */
1549 for (i
= 0; i
< sizeof(input
)/sizeof(BYTE
); i
++)
1552 for (i
= 0; i
< sizeof(output
)/sizeof(BYTE
); i
++)
1555 res
= pHashData(input
, 0, output
, 0);
1556 ok(res
== S_OK
, "Expected HashData to return S_OK, got 0x%08x\n", res
);
1558 /* The buffers should be unchanged. */
1559 for (i
= 0; i
< sizeof(input
)/sizeof(BYTE
); i
++)
1561 ok(input
[i
] == 0x00, "Expected the input buffer to be unchanged\n");
1562 if(input
[i
] != 0x00) break;
1565 for (i
= 0; i
< sizeof(output
)/sizeof(BYTE
); i
++)
1567 ok(output
[i
] == 0xFF, "Expected the output buffer to be unchanged\n");
1568 if(output
[i
] != 0xFF) break;
1571 /* Input/output parameters are not validated. */
1572 res
= pHashData((BYTE
*)0xdeadbeef, 0, (BYTE
*)0xdeadbeef, 0);
1573 ok(res
== S_OK
, "Expected HashData to return S_OK, got 0x%08x\n", res
);
1577 res
= pHashData((BYTE
*)0xdeadbeef, 1, (BYTE
*)0xdeadbeef, 1);
1578 trace("HashData returned 0x%08x\n", res
);
1582 /* ########################### */
1588 hShlwapi
= GetModuleHandleA("shlwapi.dll");
1590 /* SHCreateStreamOnFileEx was introduced in shlwapi v6.0 */
1591 pFunc
= (void*)GetProcAddress(hShlwapi
, "SHCreateStreamOnFileEx");
1593 win_skip("Too old shlwapi version\n");
1597 pUrlUnescapeA
= (void *) GetProcAddress(hShlwapi
, "UrlUnescapeA");
1598 pUrlUnescapeW
= (void *) GetProcAddress(hShlwapi
, "UrlUnescapeW");
1599 pUrlIsA
= (void *) GetProcAddress(hShlwapi
, "UrlIsA");
1600 pUrlIsW
= (void *) GetProcAddress(hShlwapi
, "UrlIsW");
1601 pUrlHashA
= (void *) GetProcAddress(hShlwapi
, "UrlHashA");
1602 pUrlHashW
= (void *) GetProcAddress(hShlwapi
, "UrlHashW");
1603 pUrlGetPartA
= (void *) GetProcAddress(hShlwapi
, "UrlGetPartA");
1604 pUrlGetPartW
= (void *) GetProcAddress(hShlwapi
, "UrlGetPartW");
1605 pUrlEscapeA
= (void *) GetProcAddress(hShlwapi
, "UrlEscapeA");
1606 pUrlEscapeW
= (void *) GetProcAddress(hShlwapi
, "UrlEscapeW");
1607 pUrlCreateFromPathA
= (void *) GetProcAddress(hShlwapi
, "UrlCreateFromPathA");
1608 pUrlCreateFromPathW
= (void *) GetProcAddress(hShlwapi
, "UrlCreateFromPathW");
1609 pUrlCombineA
= (void *) GetProcAddress(hShlwapi
, "UrlCombineA");
1610 pUrlCombineW
= (void *) GetProcAddress(hShlwapi
, "UrlCombineW");
1611 pUrlCanonicalizeA
= (void *) GetProcAddress(hShlwapi
, "UrlCanonicalizeA");
1612 pUrlCanonicalizeW
= (void *) GetProcAddress(hShlwapi
, "UrlCanonicalizeW");
1613 pUrlApplySchemeA
= (void *) GetProcAddress(hShlwapi
, "UrlApplySchemeA");
1614 pUrlApplySchemeW
= (void *) GetProcAddress(hShlwapi
, "UrlApplySchemeW");
1615 pParseURLA
= (void*)GetProcAddress(hShlwapi
, (LPCSTR
)1);
1616 pParseURLW
= (void*)GetProcAddress(hShlwapi
, (LPCSTR
)2);
1617 pHashData
= (void*)GetProcAddress(hShlwapi
, "HashData");
1619 test_UrlApplyScheme();
1622 test_UrlCanonicalizeA();
1623 test_UrlCanonicalizeW();
1627 test_UrlCreateFromPath();