1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_tools.hxx" 26 #include <tools/inetmime.hxx> 27 #include <tools/urlobj.hxx> 28 #include "com/sun/star/util/XStringWidth.hpp" 29 #include "com/sun/star/uno/Reference.hxx" 30 #include "cppuhelper/implbase1.hxx" 31 #include "osl/thread.h" 32 #include "rtl/string.h" 33 #include "rtl/string.hxx" 34 #include "rtl/textenc.h" 35 #include "rtl/ustring.h" 36 #include "rtl/ustring.hxx" 37 38 #include <cstddef> 39 #include <cstdlib> 40 #include <iostream> 41 #include <ostream> 42 #include <stdio.h> 43 44 using namespace com::sun; 45 46 std::ostream & operator <<(std::ostream & out, rtl::OUString const & value) { 47 out << rtl::OUStringToOString(value, RTL_TEXTENCODING_ASCII_US).getStr(); 48 return out; 49 } 50 51 namespace { 52 53 template< typename T1, typename T2 > bool assertEqual( 54 rtl::OUString const & message, T1 const & expected, T2 const & actual) 55 { 56 bool success = expected == actual; 57 if (!success) { 58 std::cout 59 << "FAILED " << message << ": " << expected << " != " << actual 60 << '\n'; 61 } 62 return success; 63 } 64 65 } 66 67 //============================================================================ 68 // 69 // testRelToAbs 70 // 71 //============================================================================ 72 73 struct RelToAbsTest 74 { 75 sal_Char const * m_pBase; 76 sal_Char const * m_pRel; 77 sal_Char const * m_pAbs; 78 sal_Char const * m_pAlt; 79 }; 80 81 //============================================================================ 82 bool testRelToAbs(RelToAbsTest const * pTest, std::size_t nSize) 83 { 84 bool bSuccess = true; 85 INetURLObject aBase; 86 String aTest; 87 for (std::size_t i = 0; i < nSize; ++i) 88 { 89 if (pTest[i].m_pBase) 90 { 91 aBase.SetURL(pTest[i].m_pBase); 92 } 93 if (aBase.HasError()) 94 { 95 printf(" BAD BASE %s\n", 96 pTest[i].m_pBase ? pTest[i].m_pBase : ""); 97 bSuccess = false; 98 continue; 99 } 100 INetURLObject aAbs; 101 aBase.GetNewAbsURL(pTest[i].m_pRel, &aAbs); 102 ByteString aTheAbs(String(aAbs.GetMainURL(INetURLObject::NO_DECODE)), 103 RTL_TEXTENCODING_ISO_8859_1); 104 if (!(aTheAbs.Equals(pTest[i].m_pAbs) 105 || pTest[i].m_pAlt && aTheAbs.Equals(pTest[i].m_pAlt))) 106 { 107 printf(" BAD GetNewAbsURL %s -> %s (%s)\n", pTest[i].m_pRel, 108 aTheAbs.GetBuffer(), pTest[i].m_pAbs); 109 bSuccess = false; 110 } 111 aTheAbs = ByteString( 112 String( 113 INetURLObject::GetAbsURL( 114 aBase.GetMainURL(INetURLObject::NO_DECODE), 115 UniString(pTest[i].m_pRel, RTL_TEXTENCODING_ISO_8859_1))), 116 RTL_TEXTENCODING_ISO_8859_1); 117 if (!(aTheAbs.Equals(pTest[i].m_pAbs) 118 || pTest[i].m_pAlt && aTheAbs.Equals(pTest[i].m_pAlt))) 119 { 120 printf(" BAD GetAbsURL %s -> %s (%s)\n", pTest[i].m_pRel, 121 aTheAbs.GetBuffer(), pTest[i].m_pAbs); 122 bSuccess = false; 123 } 124 } 125 printf("\n"); 126 return bSuccess; 127 } 128 129 //============================================================================ 130 // 131 // testSetFSys 132 // 133 //============================================================================ 134 135 struct SetFSysTest 136 { 137 sal_Char const * m_pPath; 138 INetURLObject::FSysStyle m_eStyle; 139 sal_Char const * m_pUrl; 140 }; 141 142 //============================================================================ 143 inline sal_Char const * toString(INetURLObject::FSysStyle eStyle) 144 { 145 static sal_Char aBuffer[5]; 146 int i = 0; 147 if (eStyle & INetURLObject::FSYS_VOS) 148 aBuffer[i++] = 'V'; 149 if (eStyle & INetURLObject::FSYS_UNX) 150 aBuffer[i++] = 'U'; 151 if (eStyle & INetURLObject::FSYS_DOS) 152 aBuffer[i++] = 'D'; 153 if (eStyle & INetURLObject::FSYS_MAC) 154 aBuffer[i++] = 'M'; 155 if (i == 0) 156 aBuffer[i++] = '-'; 157 aBuffer[i] = '\0'; 158 return aBuffer; 159 } 160 161 //============================================================================ 162 bool testSetFSys(SetFSysTest const * pTest, std::size_t nSize) 163 { 164 bool bSuccess = true; 165 String aPath; 166 for (std::size_t i = 0; i < nSize; ++i) 167 { 168 if (pTest[i].m_pPath) 169 aPath = String::CreateFromAscii(pTest[i].m_pPath); 170 if (aPath.Len() == 0) 171 { 172 printf(" NO PATH\n"); 173 continue; 174 } 175 INetURLObject aUrl1(aPath, pTest[i].m_eStyle); 176 INetURLObject aUrl2; 177 aUrl2.setFSysPath(aPath, pTest[i].m_eStyle); 178 if (aUrl1.GetMainURL(INetURLObject::NO_DECODE). 179 equalsAscii(pTest[i].m_pUrl) 180 && aUrl2.GetMainURL(INetURLObject::NO_DECODE). 181 equalsAscii(pTest[i].m_pUrl)) 182 printf(" ok %s %s -> %s\n", 183 ByteString(aPath, RTL_TEXTENCODING_ISO_8859_1).GetBuffer(), 184 toString(pTest[i].m_eStyle), pTest[i].m_pUrl); 185 else 186 { 187 String aTestA = aUrl1.GetMainURL(INetURLObject::NO_DECODE); 188 String aTestB = aUrl2.GetMainURL(INetURLObject::NO_DECODE); 189 190 printf(" BAD %s %s -> %s, %s (%s)\n", 191 ByteString(aPath, RTL_TEXTENCODING_ISO_8859_1).GetBuffer(), 192 toString(pTest[i].m_eStyle), 193 ByteString(aTestA, RTL_TEXTENCODING_ISO_8859_1).GetBuffer(), 194 ByteString(aTestB, RTL_TEXTENCODING_ISO_8859_1).GetBuffer(), 195 pTest[i].m_pUrl); 196 bSuccess = false; 197 } 198 } 199 printf("\n"); 200 return bSuccess; 201 } 202 203 //============================================================================ 204 // 205 // main 206 // 207 //============================================================================ 208 209 namespace { 210 211 class StringWidth: public cppu::WeakImplHelper1< star::util::XStringWidth > 212 { 213 public: 214 virtual sal_Int32 SAL_CALL queryStringWidth(rtl::OUString const & rString) 215 throw (star::uno::RuntimeException) 216 { 217 return rString.getLength(); 218 } 219 }; 220 221 void abbreviate(INetURLObject aObj) 222 { 223 star::uno::Reference< star::util::XStringWidth > xWidth(new StringWidth); 224 sal_Int32 nMax = aObj.GetMainURL(INetURLObject::NO_DECODE).getLength() + 10; 225 for (sal_Int32 i = -10; i <= nMax; ++i) 226 { 227 rtl::OString 228 aAbbreviated(rtl::OUStringToOString( 229 aObj.getAbbreviated(xWidth, 230 i, 231 INetURLObject::NO_DECODE), 232 RTL_TEXTENCODING_UTF8)); 233 printf( 234 "%4ld: <%s", static_cast< long int >(i), aAbbreviated.getStr()); 235 for (sal_Int32 j = aAbbreviated.getLength(); j < i; ++j) 236 printf(" "); 237 printf(">\n"); 238 } 239 } 240 241 bool test_getSegmentCount( 242 char const * url, bool ignoreFinalSlash, sal_Int32 result) 243 { 244 return 245 assertEqual( 246 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("test_getSegmentCount")), 247 result, 248 INetURLObject(rtl::OUString::createFromAscii(url)).getSegmentCount( 249 ignoreFinalSlash)); 250 } 251 252 bool test_insertName( 253 char const * url, char const * name, bool appendFinalSlash, sal_Int32 index, 254 bool ignoreFinalSlash, bool success, char const * result) 255 { 256 INetURLObject tmp(rtl::OUString::createFromAscii(url)); 257 return 258 assertEqual( 259 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("test_insertName")), 260 success, 261 tmp.insertName( 262 rtl::OUString::createFromAscii(name), appendFinalSlash, index, 263 ignoreFinalSlash)) & 264 assertEqual( 265 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("test_insertName")), 266 rtl::OUString::createFromAscii(result), 267 tmp.GetMainURL(INetURLObject::NO_DECODE)); 268 } 269 270 bool test_removeSegment( 271 char const * url, sal_Int32 index, bool ignoreFinalSlash, bool success, 272 char const * result) 273 { 274 INetURLObject tmp(rtl::OUString::createFromAscii(url)); 275 return 276 assertEqual( 277 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("test_removeSegment")), 278 success, tmp.removeSegment(index, ignoreFinalSlash)) & 279 assertEqual( 280 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("test_removeSegment")), 281 rtl::OUString::createFromAscii(result), 282 tmp.GetMainURL(INetURLObject::NO_DECODE)); 283 } 284 285 } 286 287 int 288 #if defined WNT 289 __cdecl 290 #endif // WNT 291 main() 292 { 293 bool bSuccess = true; 294 295 if (true) 296 { 297 // The data for this test is taken from the files 298 // <http://www.ics.uci.edu/~fielding/url/testN.html> with N = 1, 299 // ..., 3, as of August 28, 2000: 300 static RelToAbsTest const aTest[] 301 = { //{ "http://a/b/c/d;p?q", "g:h", "g:h", 0 }, 302 { "http://a/b/c/d;p?q", "g", "http://a/b/c/g", 0 }, 303 { 0, "./g", "http://a/b/c/g", 0 }, 304 { 0, "g/", "http://a/b/c/g/", 0 }, 305 { 0, "/g", "http://a/g", 0 }, 306 { 0, "//g", "http://g", "http://g/" }, 307 //{ 0, "?y", "http://a/b/c/d;p?y", 0 }, 308 { 0, "g?y", "http://a/b/c/g?y", 0 }, 309 //{ 0, "#s", "http://a/b/c/d;p?q#s", 0 }, 310 { 0, "g#s", "http://a/b/c/g#s", 0 }, 311 { 0, "g?y#s", "http://a/b/c/g?y#s", 0 }, 312 { 0, ";x", "http://a/b/c/;x", 0 }, 313 { 0, "g;x", "http://a/b/c/g;x", 0 }, 314 { 0, "g;x?y#s", "http://a/b/c/g;x?y#s", 0 }, 315 { 0, ".", "http://a/b/c/", 0 }, 316 { 0, "./", "http://a/b/c/", 0 }, 317 { 0, "..", "http://a/b/", 0 }, 318 { 0, "../", "http://a/b/", 0 }, 319 { 0, "../g", "http://a/b/g", 0 }, 320 { 0, "../..", "http://a/", 0 }, 321 { 0, "../../", "http://a/", 0 }, 322 { 0, "../../g", "http://a/g", 0 }, 323 //{ 0, "", "http://a/b/c/d;p?q", 0 }, 324 { 0, "../../../g", "http://a/../g", "http://a/g" }, 325 { 0, "../../../../g", "http://a/../../g", "http://a/g" }, 326 { 0, "/./g", "http://a/./g", 0 }, 327 { 0, "/../g", "http://a/../g", 0 }, 328 { 0, "g.", "http://a/b/c/g.", 0 }, 329 { 0, ".g", "http://a/b/c/.g", 0 }, 330 { 0, "g..", "http://a/b/c/g..", 0 }, 331 { 0, "..g", "http://a/b/c/..g", 0 }, 332 { 0, "./../g", "http://a/b/g", 0 }, 333 { 0, "./g/.", "http://a/b/c/g/", 0 }, 334 { 0, "g/./h", "http://a/b/c/g/h", 0 }, 335 { 0, "g/../h", "http://a/b/c/h", 0 }, 336 { 0, "g;x=1/./y", "http://a/b/c/g;x=1/y", 0 }, 337 { 0, "g;x=1/../y", "http://a/b/c/y", 0 }, 338 { 0, "g?y/./x", "http://a/b/c/g?y/./x", 0 }, 339 { 0, "g?y/../x", "http://a/b/c/g?y/../x", 0 }, 340 { 0, "g#s/./x", "http://a/b/c/g#s/./x", 0 }, 341 { 0, "g#s/../x", "http://a/b/c/g#s/../x", 0 }, 342 { 0, "http:g", "http:g", "http://a/b/c/g" }, 343 //{ 0, "http:", "http:", 0 }, 344 { "http://a/b/c/d;p?q=1/2", "g", "http://a/b/c/g", 0 }, 345 { 0, "./g", "http://a/b/c/g", 0 }, 346 { 0, "g/", "http://a/b/c/g/", 0 }, 347 { 0, "/g", "http://a/g", 0 }, 348 { 0, "//g", "http://g", "http://g/" }, 349 { 0, "g?y", "http://a/b/c/g?y", 0 }, 350 { 0, "g?y/./x", "http://a/b/c/g?y/./x", 0 }, 351 { 0, "g?y/../x", "http://a/b/c/g?y/../x", 0 }, 352 { 0, "g#s", "http://a/b/c/g#s", 0 }, 353 { 0, "g#s/./x", "http://a/b/c/g#s/./x", 0 }, 354 { 0, "g#s/../x", "http://a/b/c/g#s/../x", 0 }, 355 { 0, "./", "http://a/b/c/", 0 }, 356 { 0, "../", "http://a/b/", 0 }, 357 { 0, "../g", "http://a/b/g", 0 }, 358 { 0, "../../", "http://a/", 0 }, 359 { 0, "../../g", "http://a/g", 0 }, 360 { "http://a/b/c/d;p=1/2?q", "g", "http://a/b/c/d;p=1/g", 0 }, 361 { 0, "./g", "http://a/b/c/d;p=1/g", 0 }, 362 { 0, "g/", "http://a/b/c/d;p=1/g/", 0 }, 363 { 0, "g?y", "http://a/b/c/d;p=1/g?y", 0 }, 364 { 0, ";x", "http://a/b/c/d;p=1/;x", 0 }, 365 { 0, "g;x", "http://a/b/c/d;p=1/g;x", 0 }, 366 { 0, "g;x=1/./y", "http://a/b/c/d;p=1/g;x=1/y", 0 }, 367 { 0, "g;x=1/../y", "http://a/b/c/d;p=1/y", 0 }, 368 { 0, "./", "http://a/b/c/d;p=1/", 0 }, 369 { 0, "../", "http://a/b/c/", 0 }, 370 { 0, "../g", "http://a/b/c/g", 0 }, 371 { 0, "../../", "http://a/b/", 0 }, 372 { 0, "../../g", "http://a/b/g", 0 }, 373 { "file:///", "generic:", "file:///generic:", 0 }, 374 { 0, "generic:#fragment", "file:///generic:#fragment", 0 }, 375 { 0, "generic:something", "generic:something", 0 }, 376 { 0, "c:/foo/bar", "file:///c:/foo/bar", 0 }, 377 { 0, "c:\\foo\\bar", "file:///c:%5Cfoo%5Cbar", 0 } }; 378 if (!testRelToAbs(aTest, sizeof aTest / sizeof (RelToAbsTest))) 379 bSuccess = false; 380 } 381 382 if (false) 383 { 384 static SetFSysTest const aTest[] 385 = { { "//.", INetURLObject::FSysStyle(0), "" }, 386 { 0, INetURLObject::FSysStyle(1), "file:///" }, 387 { 0, INetURLObject::FSysStyle(2), "file:////." }, 388 { 0, INetURLObject::FSysStyle(3), "file:///" }, 389 { 0, INetURLObject::FSysStyle(4), "file:///%2F%2F." }, 390 { 0, INetURLObject::FSysStyle(5), "file:///" }, 391 { 0, INetURLObject::FSysStyle(6), "file:////." }, 392 { 0, INetURLObject::FSysStyle(7), "file:///" }, 393 { 0, INetURLObject::FSysStyle(8), "file:///%2F%2F." }, 394 { 0, INetURLObject::FSysStyle(9), "file:///" }, 395 { 0, INetURLObject::FSysStyle(10), "file:////." }, 396 { 0, INetURLObject::FSysStyle(11), "file:///" }, 397 { 0, INetURLObject::FSysStyle(12), "file:///%2F%2F." }, 398 { 0, INetURLObject::FSysStyle(13), "file:///" }, 399 { 0, INetURLObject::FSysStyle(14), "file:////." }, 400 { 0, INetURLObject::FSysStyle(15), "file:///" }, 401 { "//./", INetURLObject::FSysStyle(0), "" }, 402 { 0, INetURLObject::FSysStyle(1), "file:///" }, 403 { 0, INetURLObject::FSysStyle(2), "file:////./" }, 404 { 0, INetURLObject::FSysStyle(3), "file:///" }, 405 { 0, INetURLObject::FSysStyle(4), "file:///%2F%2F.%2F" }, 406 { 0, INetURLObject::FSysStyle(5), "file:///" }, 407 { 0, INetURLObject::FSysStyle(6), "file:////./" }, 408 { 0, INetURLObject::FSysStyle(7), "file:///" }, 409 { 0, INetURLObject::FSysStyle(8), "file:///%2F%2F.%2F" }, 410 { 0, INetURLObject::FSysStyle(9), "file:///" }, 411 { 0, INetURLObject::FSysStyle(10), "file:////./" }, 412 { 0, INetURLObject::FSysStyle(11), "file:///" }, 413 { 0, INetURLObject::FSysStyle(12), "file:///%2F%2F.%2F" }, 414 { 0, INetURLObject::FSysStyle(13), "file:///" }, 415 { 0, INetURLObject::FSysStyle(14), "file:////./" }, 416 { 0, INetURLObject::FSysStyle(15), "file:///" }, 417 { "//./a/b\\c:d", INetURLObject::FSysStyle(0), "" }, 418 { 0, INetURLObject::FSysStyle(1), "file:///a/b%5Cc:d" }, 419 { 0, INetURLObject::FSysStyle(2), "file:////./a/b%5Cc:d" }, 420 { 0, INetURLObject::FSysStyle(3), "file:///a/b%5Cc:d" }, 421 { 0, INetURLObject::FSysStyle(4), "file:///%2F%2F.%2Fa%2Fb/c:d" }, 422 { 0, INetURLObject::FSysStyle(5), "file:///a/b%5Cc:d" }, 423 { 0, INetURLObject::FSysStyle(6), "file:////./a/b%5Cc:d" }, 424 { 0, INetURLObject::FSysStyle(7), "file:///a/b%5Cc:d" }, 425 { 0, INetURLObject::FSysStyle(8), "file:///%2F%2F.%2Fa%2Fb%5Cc/d" }, 426 { 0, INetURLObject::FSysStyle(9), "file:///a/b%5Cc:d" }, 427 { 0, INetURLObject::FSysStyle(10), "file:////./a/b%5Cc:d" }, 428 { 0, INetURLObject::FSysStyle(11), "file:///a/b%5Cc:d" }, 429 { 0, INetURLObject::FSysStyle(12), "file:///%2F%2F.%2Fa%2Fb/c:d" }, 430 { 0, INetURLObject::FSysStyle(13), "file:///a/b%5Cc:d" }, 431 { 0, INetURLObject::FSysStyle(14), "file:////./a/b%5Cc:d" }, 432 { 0, INetURLObject::FSysStyle(15), "file:///a/b%5Cc:d" } }; 433 if (!testSetFSys(aTest, sizeof aTest / sizeof (SetFSysTest))) 434 bSuccess = false; 435 } 436 437 /* 438 if (false) 439 { 440 bool bAbs = false; 441 INetURLObject aUrl1(INetURLObject().smartRel2Abs(L"/export/home/mba/Office/user/Basic/soffice.sbl", bAbs)); 442 443 INetURLObject aUrl2a(L"/export/home/mba/Office/user/Basic/soffice.sbl", INET_PROT_FILE); 444 445 INetURLObject aUrl2b(L"file:///export/home/mba/Office/user/Basic/soffice.sbl", INET_PROT_FILE); 446 447 INetURLObject aUrl3a(L"/export/home/mba/Office/user/Basic/soffice.sbl", INetURLObject::FSYS_DETECT); 448 449 INetURLObject aUrl3b(L"file:///export/home/mba/Office/user/Basic/soffice.sbl", INetURLObject::FSYS_DETECT); 450 } 451 */ 452 453 if (true) 454 { 455 INetURLObject aUrl1("http://host:1234/xy/~zw?xxx=yyy"); 456 if (aUrl1.HasError()) 457 { 458 printf("BAD http\n"); 459 bSuccess = false; 460 } 461 INetURLObject aUrl2("vnd.sun.star.webdav://host:1234/xy/~zw?xxx=yyy"); 462 if (aUrl2.HasError()) 463 { 464 printf("BAD vnd.sun.star.webdav\n"); 465 bSuccess = false; 466 } 467 } 468 469 if (true) 470 { 471 struct Test { char const * in; char const * out; }; 472 static Test const aTest[] 473 = { { "vnd.sun.star.help://", "vnd.sun.star.help:///" }, 474 { "vnd.sun.star.help:///", 0 }, 475 { "vnd.sun.star.help://swriter", 476 "vnd.sun.star.help://swriter/" }, 477 { "vnd.sun.star.help://swriter/", 0 }, 478 { "vnd.sun.star.help://swriter/12345", 0 }, 479 { "vnd.sun.star.help://swriter/1234X", 0 }, 480 { "vnd.sun.star.help://swriter/?a=b?c=d", 0 }, 481 { "vnd.sun.star.help://swriter/12345?a=b?c=d", 0 }, 482 { "vnd.sun.star.help://swriter/12345???", 0 }, 483 { "vnd.sun.star.help://swriter/#xxx", 0 }, 484 { "vnd.sun.star.help://swriter/12345#xxx", 0 }, 485 { "vnd.sun.star.help://swriter/1234X#xxx", 0 }, 486 { "vnd.sun.star.help://swriter/?a=b?c=d#xxx", 0 }, 487 { "vnd.sun.star.help://swriter/12345?a=b?c=d#xxx", 0 }, 488 { "vnd.sun.star.help://swriter/12345???#xxx", 0 }, 489 { "vnd.sun.star.help://swriter/start", 0 }, 490 { "vnd.sun.star.help://swriter/s/t/a/r/t", 0 }, 491 { "vnd.sun.star.help://swriter/a%2Fb%3Fc%2534d/e?f", 0 }, 492 { "vnd.sun.star.help://swriter?foo", 493 "vnd.sun.star.help://swriter/?foo" }, 494 { "vnd.sun.star.help://swriter/?foo", 0 } }; 495 for (std::size_t i = 0; i < sizeof aTest / sizeof aTest[0]; ++i) 496 { 497 INetURLObject aUrl(aTest[i].in); 498 if (aUrl.HasError()) 499 printf("BAD %s\n", aTest[i].in); 500 else if (aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI). 501 equalsAscii( 502 aTest[i].out == 0 ? aTest[i].in : aTest[i].out) 503 != sal_True) 504 { 505 String sTest(aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI)); 506 printf("BAD %s -> %s\n", 507 aTest[i].in, 508 ByteString(sTest, RTL_TEXTENCODING_ASCII_US). 509 GetBuffer()); 510 } 511 } 512 } 513 514 if (true) 515 { 516 static sal_Char const * const aTest[] 517 = { /*TODO "vnd.sun.star.wfs://",*/ 518 /*TODO "vnd.sun.star.wfs://LocalHost",*/ 519 /*TODO "vnd.sun.star.wfs:///c|/xyz/",*/ 520 /*TODO "vnd.sun.star.wfs://xxx/yyy?zzz",*/ 521 "vnd.sun.star.wfs:///x/y/z", 522 "vnd.sun.star.generic:///x/y/z", 523 "vnd.sun.star.generic://host:34/x/y/z" 524 /*TODO "wfs://",*/ 525 /*TODO "wfs://LocalHost",*/ 526 /*TODO "wfs:///c|/xyz/",*/ 527 /*TODO "wfs://xxx/yyy?zzz",*/ 528 /*TODO "wfs:///x/y/z"*/ }; 529 for (std::size_t i = 0; i < sizeof aTest / sizeof aTest[0]; ++i) 530 { 531 INetURLObject aUrl(aTest[i]); 532 if (aUrl.HasError()) 533 printf("BAD %s\n", aTest[i]); 534 else 535 { 536 if (aUrl.GetProtocol() != INET_PROT_GENERIC) { 537 printf("BAD PROTOCOL %i -> %i\n", 538 aUrl.GetProtocol(), 539 INET_PROT_GENERIC); 540 } 541 if (aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI). 542 equalsAscii(aTest[i]) != sal_True) 543 { 544 String sTest(aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI)); 545 printf("BAD %s -> %s\n", 546 aTest[i], 547 ByteString(sTest, RTL_TEXTENCODING_ASCII_US).GetBuffer()); 548 } 549 } 550 } 551 } 552 553 if (true) 554 { 555 static sal_Char const * const aTest[] 556 = { /*TODO "vnd.sun.star.pkg:",*/ 557 /*TODO "vnd.sun.star.pkg:/",*/ 558 /*TODO "vnd.sun.star.pkg://abc",*/ 559 /*TODO "vnd.sun.star.pkg://file:%2F%2F%2Fa:%2Fb%20c",*/ 560 "vnd.sun.star.pkg://file:%2F%2F%2Fa:%2Fb%20c/", 561 "vnd.sun.star.pkg://file:%2F%2F%2Fa:%2Fb%20c/xx", 562 /*TODO "vnd.sun.star.pkg://file:%2F%2F%2Fa:%2Fb%20c/xx;yy",*/ 563 "vnd.sun.star.pkg://file:%2F%2F%2Fa:%2Fb%20c/xx//yy" }; 564 for (std::size_t i = 0; i < sizeof aTest / sizeof aTest[0]; ++i) 565 { 566 INetURLObject aUrl(aTest[i]); 567 if (aUrl.HasError()) 568 printf("BAD %s\n", aTest[i]); 569 else if (aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI). 570 equalsAscii(aTest[i]) != sal_True) 571 { 572 String sTest(aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI)); 573 printf("BAD %s -> %s\n", 574 aTest[i], 575 ByteString(sTest, RTL_TEXTENCODING_ASCII_US).GetBuffer()); 576 } 577 } 578 } 579 580 if (true) 581 { 582 static sal_Char const * const aTest[] 583 = { /*TODO "vnd.sun.star.cmd:",*/ 584 /*TODO "vnd.sun.star.cmd:/",*/ 585 "vnd.sun.star.cmd:logout", 586 "vnd.sun.star.cmd:log/out", 587 /*TODO "vnd.sun.star.cmd:[logout]",*/ 588 "vnd.sun.star.cmd:log[out]" }; 589 for (std::size_t i = 0; i < sizeof aTest / sizeof aTest[0]; ++i) 590 { 591 INetURLObject aUrl(aTest[i]); 592 if (aUrl.HasError()) 593 printf("BAD %s\n", aTest[i]); 594 else if (aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI). 595 equalsAscii(aTest[i]) != sal_True) 596 { 597 String sTest(aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI)); 598 printf("BAD %s -> %s\n", 599 aTest[i], 600 ByteString(sTest, RTL_TEXTENCODING_ASCII_US).GetBuffer()); 601 } 602 } 603 } 604 605 if (true) 606 { 607 rtl::OUString 608 aParameters(rtl::OUString::createFromAscii("; CharSet=UTF-8 ; Blubber=Blob")); 609 sal_Unicode const * pBegin = aParameters.getStr(); 610 sal_Unicode const * pEnd = pBegin + aParameters.getLength(); 611 INetContentTypeParameterList aList; 612 if (INetMIME::scanParameters(pBegin, pEnd, &aList) == pEnd) 613 { 614 ULONG nCount = aList.Count(); 615 for (ULONG i = 0; i < nCount; ++i) 616 { 617 INetContentTypeParameter const * p = aList.GetObject(i); 618 if (p) 619 { 620 /* 621 printf("attribute: '%s'\n charset: '%s'\n language: '%s'\n value: '%s'\n converted: %s\n", 622 p->m_sAttribute.GetBuffer(), 623 p->m_sCharset.GetBuffer(), 624 p->m_sLanguage.GetBuffer(), 625 rtl::OUStringToOString(p->m_sValue,RTL_TEXTENCODING_UTF8).getStr(), 626 p->m_bConverted ? "true" : "false"); 627 */ 628 } 629 else 630 printf("BAD INetContentTypeParameter\n"); 631 } 632 } 633 else 634 { 635 printf("BAD INetMIME::scanParameters()\n"); 636 bSuccess = false; 637 } 638 } 639 640 if (true) 641 { 642 { 643 INetURLObject aObj; 644 aObj.setFSysPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a:")), 645 INetURLObject::FSYS_DETECT); 646 if (!rtl::OUString(aObj.GetMainURL(INetURLObject::NO_DECODE)). 647 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("file:///a:"))) 648 { 649 printf("BAD setFSysPath(\"a:\")\n"); 650 bSuccess = false; 651 } 652 } 653 { 654 INetURLObject aObj; 655 aObj.setFSysPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 656 "a:/")), 657 INetURLObject::FSYS_DETECT); 658 if (!rtl::OUString(aObj.GetMainURL(INetURLObject::NO_DECODE)). 659 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("file:///a:/"))) 660 { 661 printf("BAD setFSysPath(\"a:/\")\n"); 662 bSuccess = false; 663 } 664 } 665 { 666 INetURLObject aObj; 667 aObj.setFSysPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 668 "a:\\")), 669 INetURLObject::FSYS_DETECT); 670 if (!rtl::OUString(aObj.GetMainURL(INetURLObject::NO_DECODE)). 671 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("file:///a:/"))) 672 { 673 printf("BAD setFSysPath(\"a:\\\")\n"); 674 bSuccess = false; 675 } 676 } 677 678 if (!rtl::OUString(INetURLObject("file:///a:"). 679 getFSysPath(INetURLObject::FSYS_DETECT)). 680 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("a:"))) 681 { 682 printf("BAD getFSysPath(\"file:///a:\")\n"); 683 bSuccess = false; 684 } 685 if (!rtl::OUString(INetURLObject("file:///a:/"). 686 getFSysPath(INetURLObject::FSYS_DETECT)). 687 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("a:\\"))) 688 { 689 printf("BAD getFSysPath(\"file:///a:/\")\n"); 690 bSuccess = false; 691 } 692 693 { 694 bool bWasAbsolute; 695 if (!rtl::OUString(INetURLObject(rtl::OUString( 696 RTL_CONSTASCII_USTRINGPARAM( 697 "file:///"))). 698 smartRel2Abs( 699 rtl::OUString( 700 RTL_CONSTASCII_USTRINGPARAM( 701 "a:")), 702 bWasAbsolute). 703 GetMainURL(INetURLObject::NO_DECODE)). 704 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("file:///a:")) 705 || !bWasAbsolute) 706 { 707 printf("BAD smartRel2Abs(\"a:\")\n"); 708 bSuccess = false; 709 } 710 } 711 { 712 bool bWasAbsolute; 713 if (!rtl::OUString(INetURLObject(rtl::OUString( 714 RTL_CONSTASCII_USTRINGPARAM( 715 "file:///"))). 716 smartRel2Abs( 717 rtl::OUString( 718 RTL_CONSTASCII_USTRINGPARAM( 719 "a:/")), 720 bWasAbsolute). 721 GetMainURL(INetURLObject::NO_DECODE)). 722 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("file:///a:/")) 723 || !bWasAbsolute) 724 { 725 printf("BAD smartRel2Abs(\"a:/\")\n"); 726 bSuccess = false; 727 } 728 } 729 { 730 bool bWasAbsolute; 731 if (!rtl::OUString(INetURLObject(rtl::OUString( 732 RTL_CONSTASCII_USTRINGPARAM( 733 "file:///"))). 734 smartRel2Abs( 735 rtl::OUString( 736 RTL_CONSTASCII_USTRINGPARAM( 737 "a:\\")), 738 bWasAbsolute). 739 GetMainURL(INetURLObject::NO_DECODE)). 740 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("file:///a:/")) 741 || !bWasAbsolute) 742 { 743 printf("BAD smartRel2Abs(\"a:\\\")\n"); 744 bSuccess = false; 745 } 746 } 747 { 748 bool bWasAbsolute; 749 if (!rtl::OUString(INetURLObject(rtl::OUString( 750 RTL_CONSTASCII_USTRINGPARAM( 751 "file:///"))). 752 smartRel2Abs( 753 rtl::OUString( 754 RTL_CONSTASCII_USTRINGPARAM( 755 "generic:")), 756 bWasAbsolute). 757 GetMainURL(INetURLObject::NO_DECODE)). 758 equalsAsciiL( 759 RTL_CONSTASCII_STRINGPARAM("file:///generic:")) 760 || bWasAbsolute) 761 { 762 printf("BAD smartRel2Abs(\"generic:\")\n"); 763 bSuccess = false; 764 } 765 } 766 { 767 bool bWasAbsolute; 768 if (!rtl::OUString(INetURLObject(rtl::OUString( 769 RTL_CONSTASCII_USTRINGPARAM( 770 "file:///"))). 771 smartRel2Abs( 772 rtl::OUString( 773 RTL_CONSTASCII_USTRINGPARAM( 774 "generic:#fragment")), 775 bWasAbsolute). 776 GetMainURL(INetURLObject::NO_DECODE)). 777 equalsAsciiL( 778 RTL_CONSTASCII_STRINGPARAM( 779 "file:///generic:#fragment")) 780 || bWasAbsolute) 781 { 782 printf("BAD smartRel2Abs(\"generic:#fragment\")\n"); 783 bSuccess = false; 784 } 785 } 786 { 787 bool bWasAbsolute; 788 if (!rtl::OUString(INetURLObject(rtl::OUString( 789 RTL_CONSTASCII_USTRINGPARAM( 790 "file:///"))). 791 smartRel2Abs( 792 rtl::OUString( 793 RTL_CONSTASCII_USTRINGPARAM( 794 "generic:something")), 795 bWasAbsolute). 796 GetMainURL(INetURLObject::NO_DECODE)). 797 equalsAsciiL( 798 RTL_CONSTASCII_STRINGPARAM("generic:something")) 799 || !bWasAbsolute) 800 { 801 printf("BAD smartRel2Abs(\"generic:something\")\n"); 802 bSuccess = false; 803 } 804 } 805 { 806 bool bWasAbsolute; 807 if (!rtl::OUString(INetURLObject(rtl::OUString( 808 RTL_CONSTASCII_USTRINGPARAM( 809 "file:///"))). 810 smartRel2Abs( 811 rtl::OUString( 812 RTL_CONSTASCII_USTRINGPARAM( 813 "\\\\unc_host\\path")), 814 bWasAbsolute). 815 GetMainURL(INetURLObject::NO_DECODE)). 816 equalsAsciiL( 817 RTL_CONSTASCII_STRINGPARAM("file://unc_host/path")) 818 || !bWasAbsolute) 819 { 820 printf("BAD smartRel2Abs(\"\\\\unc_host\\path\")\n"); 821 bSuccess = false; 822 } 823 } 824 } 825 826 if (true) 827 { 828 /*TODO 829 { 830 INetURLObject aObj(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("http://xxx/yyy?abc/def~"))); 831 if (!rtl::OUString(aObj.GetMainURL(INetURLObject::NO_DECODE)). 832 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("http://xxx/yyy?abc%2Fdef%7E"))) 833 { 834 printf("BAD http query 1\n"); 835 bSuccess = false; 836 } 837 } 838 */ 839 { 840 INetURLObject aObj(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("https://xxx/yyy?abc/def~"))); 841 if (!rtl::OUString(aObj.GetMainURL(INetURLObject::NO_DECODE)). 842 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("https://xxx/yyy?abc/def~"))) 843 { 844 printf("BAD https query 1\n"); 845 bSuccess = false; 846 } 847 } 848 /*TODO 849 { 850 INetURLObject aObj(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("http://xxx/yyy"))); 851 aObj.SetParam("abc/def~"); 852 if (!rtl::OUString(aObj.GetMainURL(INetURLObject::NO_DECODE)). 853 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("http://xxx/yyy?abc%2Fdef%7E"))) 854 { 855 printf("BAD http query 2\n"); 856 bSuccess = false; 857 } 858 } 859 */ 860 { 861 INetURLObject aObj(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("https://xxx/yyy"))); 862 aObj.SetParam("abc/def~"); 863 if (!rtl::OUString(aObj.GetMainURL(INetURLObject::NO_DECODE)). 864 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("https://xxx/yyy?abc/def~"))) 865 { 866 printf("BAD https query 2\n"); 867 bSuccess = false; 868 } 869 } 870 } 871 872 if (true) 873 { 874 if (INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.hier:"))).HasError()) 875 { 876 printf("BAD vnd.sun.star.hier test 1\n"); 877 bSuccess = false; 878 } 879 if (!INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.hier://"))).HasError()) 880 { 881 printf("BAD vnd.sun.star.hier test 2\n"); 882 bSuccess = false; 883 } 884 if (!INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.hier:///"))).HasError()) 885 { 886 printf("BAD vnd.sun.star.hier test 3\n"); 887 bSuccess = false; 888 } 889 if (!INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.hier:///abc"))).HasError()) 890 { 891 printf("BAD vnd.sun.star.hier test 4\n"); 892 bSuccess = false; 893 } 894 if (INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.hier://abc"))).HasError()) 895 { 896 printf("BAD vnd.sun.star.hier test 5\n"); 897 bSuccess = false; 898 } 899 if (INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.hier://abc/def"))).HasError()) 900 { 901 printf("BAD vnd.sun.star.hier test 6\n"); 902 bSuccess = false; 903 } 904 } 905 906 if (false) 907 { 908 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 909 "file:///")))); 910 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 911 "file:///a")))); 912 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 913 "file:///a/def/")))); 914 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 915 "file:///ab/def/")))); 916 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 917 "file:///abc/def/")))); 918 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 919 "file:///a/def")))); 920 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 921 "file:///ab/def")))); 922 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 923 "file:///abc/def")))); 924 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 925 "file:///abcdef/d")))); 926 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 927 "file:///abcdef/de")))); 928 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 929 "file:///abcdef/def")))); 930 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 931 "file://some.host/")))); 932 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 933 "file://some.host/a")))); 934 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 935 "file://some.host/a/def/")))); 936 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 937 "file://some.host/ab/def/")))); 938 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 939 "file://some.host/abc/def/")))); 940 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 941 "file://some.host/a/def")))); 942 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 943 "file://some.host/ab/def")))); 944 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 945 "file://some.host/abc/def")))); 946 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 947 "file://some.host/abcdef/d")))); 948 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 949 "file://some.host/abcdef/de")))); 950 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 951 "file://some.host/abcdef/def")))); 952 abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 953 "http://foo/aa/bb//cc/d/eee////ff/ggggggg/hhhhhh/iii/j/" 954 "kkkkkkkkkkkkk/ll/mm/nn/oo/p")))); 955 } 956 957 if (true) 958 { 959 { 960 rtl::OUString 961 aBase(RTL_CONSTASCII_USTRINGPARAM("file:///a:/b/c")); 962 rtl::OUString aAbs(RTL_CONSTASCII_USTRINGPARAM("file:///a:/d/e")); 963 rtl::OUString aRel(INetURLObject::GetRelURL(aBase, aAbs)); 964 if (!aRel.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("../d/e"))) 965 { 966 printf("BAD GetRelURL(%s, %s) = %s\n", 967 rtl::OUStringToOString(aBase, RTL_TEXTENCODING_UTF8). 968 getStr(), 969 rtl::OUStringToOString(aAbs, RTL_TEXTENCODING_UTF8). 970 getStr(), 971 rtl::OUStringToOString(aRel, RTL_TEXTENCODING_UTF8). 972 getStr()); 973 bSuccess = false; 974 } 975 } 976 { 977 rtl::OUString 978 aBase(RTL_CONSTASCII_USTRINGPARAM("file:///a:/b/c")); 979 rtl::OUString aAbs(RTL_CONSTASCII_USTRINGPARAM("file:///d:/e/f")); 980 rtl::OUString aRel(INetURLObject::GetRelURL(aBase, aAbs)); 981 if (aRel != aAbs) 982 { 983 printf("BAD GetRelURL(%s, %s) = %s\n", 984 rtl::OUStringToOString(aBase, RTL_TEXTENCODING_UTF8). 985 getStr(), 986 rtl::OUStringToOString(aAbs, RTL_TEXTENCODING_UTF8). 987 getStr(), 988 rtl::OUStringToOString(aRel, RTL_TEXTENCODING_UTF8). 989 getStr()); 990 bSuccess = false; 991 } 992 } 993 { 994 rtl::OUString 995 aBase(RTL_CONSTASCII_USTRINGPARAM("file:///a:/b/c")); 996 rtl::OUString aAbs(RTL_CONSTASCII_USTRINGPARAM("file:///d/e/f")); 997 rtl::OUString aRel(INetURLObject::GetRelURL(aBase, aAbs)); 998 if (!aRel.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("../../d/e/f"))) 999 { 1000 printf("BAD GetRelURL(%s, %s) = %s\n", 1001 rtl::OUStringToOString(aBase, RTL_TEXTENCODING_UTF8). 1002 getStr(), 1003 rtl::OUStringToOString(aAbs, RTL_TEXTENCODING_UTF8). 1004 getStr(), 1005 rtl::OUStringToOString(aRel, RTL_TEXTENCODING_UTF8). 1006 getStr()); 1007 bSuccess = false; 1008 } 1009 } 1010 { 1011 rtl::OUString 1012 aBase(RTL_CONSTASCII_USTRINGPARAM("file:///a:/b/c")); 1013 rtl::OUString aAbs(RTL_CONSTASCII_USTRINGPARAM("file:///d:/e/f")); 1014 rtl::OUString 1015 aRel(INetURLObject::GetRelURL(aBase, 1016 aAbs, 1017 INetURLObject::WAS_ENCODED, 1018 INetURLObject::DECODE_TO_IURI, 1019 RTL_TEXTENCODING_UTF8, 1020 INetURLObject::FSYS_UNX)); 1021 if (!aRel.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( 1022 "../../d:/e/f"))) 1023 { 1024 printf("BAD GetRelURL(%s, %s) = %s\n", 1025 rtl::OUStringToOString(aBase, RTL_TEXTENCODING_UTF8). 1026 getStr(), 1027 rtl::OUStringToOString(aAbs, RTL_TEXTENCODING_UTF8). 1028 getStr(), 1029 rtl::OUStringToOString(aRel, RTL_TEXTENCODING_UTF8). 1030 getStr()); 1031 bSuccess = false; 1032 } 1033 } 1034 /*TODO 1035 { 1036 rtl::OUString 1037 aBase(RTL_CONSTASCII_USTRINGPARAM("file:///test.html")); 1038 rtl::OUString 1039 aAbs(RTL_CONSTASCII_USTRINGPARAM("/images/myimage.gif")); 1040 rtl::OUString aRel(INetURLObject::GetRelURL(aBase, aAbs)); 1041 if (aRel != aAbs) 1042 { 1043 printf("BAD GetRelURL(%s, %s) = %s\n", 1044 rtl::OUStringToOString(aBase, RTL_TEXTENCODING_UTF8). 1045 getStr(), 1046 rtl::OUStringToOString(aAbs, RTL_TEXTENCODING_UTF8). 1047 getStr(), 1048 rtl::OUStringToOString(aRel, RTL_TEXTENCODING_UTF8). 1049 getStr()); 1050 bSuccess = false; 1051 } 1052 } 1053 */ 1054 } 1055 1056 if (true) 1057 { 1058 INetURLObject aUrl(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 1059 "file://host/dir/file"))); 1060 rtl::OUString aPath; 1061 aPath = aUrl.getFSysPath(INetURLObject::FSYS_DETECT); 1062 if (!aPath. 1063 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("//host/dir/file"))) 1064 { 1065 printf("BAD getFSysPath(VOS|UNX|DOS|MAC) = %s\n", 1066 rtl::OUStringToOString(aPath, RTL_TEXTENCODING_UTF8). 1067 getStr()); 1068 bSuccess = false; 1069 } 1070 aPath = aUrl.getFSysPath(INetURLObject::FSysStyle( 1071 INetURLObject::FSYS_UNX 1072 | INetURLObject::FSYS_DOS 1073 | INetURLObject::FSYS_MAC)); 1074 if (!aPath.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( 1075 "\\\\host\\dir\\file"))) 1076 { 1077 printf("BAD getFSysPath(UNX|DOS|MAC) = %s\n", 1078 rtl::OUStringToOString(aPath, RTL_TEXTENCODING_UTF8). 1079 getStr()); 1080 bSuccess = false; 1081 } 1082 aPath = aUrl.getFSysPath(INetURLObject::FSysStyle( 1083 INetURLObject::FSYS_UNX 1084 | INetURLObject::FSYS_MAC)); 1085 if (aPath.getLength() != 0) 1086 { 1087 printf("BAD getFSysPath(UNX|MAC) = %s\n", 1088 rtl::OUStringToOString(aPath, RTL_TEXTENCODING_UTF8). 1089 getStr()); 1090 bSuccess = false; 1091 } 1092 } 1093 1094 if (true) 1095 { 1096 { 1097 INetURLObject aUrl1(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.odma:"))); 1098 rtl::OUString aUrl2(aUrl1.GetMainURL( 1099 INetURLObject::DECODE_TO_IURI)); 1100 if (!aUrl2.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.odma:/"))) 1101 { 1102 printf("BAD vnd.sun.star.odma: != %s\n", 1103 rtl::OUStringToOString(aUrl2, RTL_TEXTENCODING_UTF8). 1104 getStr()); 1105 bSuccess = false; 1106 } 1107 } 1108 { 1109 INetURLObject aUrl1(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.odma:/"))); 1110 rtl::OUString aUrl2(aUrl1.GetMainURL( 1111 INetURLObject::DECODE_TO_IURI)); 1112 if (!aUrl2.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.odma:/"))) 1113 { 1114 printf("BAD vnd.sun.star.odma:/ != %s\n", 1115 rtl::OUStringToOString(aUrl2, RTL_TEXTENCODING_UTF8). 1116 getStr()); 1117 bSuccess = false; 1118 } 1119 } 1120 { 1121 INetURLObject aUrl1(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.odma:/bla/bla"))); 1122 rtl::OUString aUrl2(aUrl1.GetMainURL( 1123 INetURLObject::DECODE_TO_IURI)); 1124 if (!aUrl2.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.odma:/bla%2Fbla"))) 1125 { 1126 printf("BAD vnd.sun.star.odma:/bla/bla != %s\n", 1127 rtl::OUStringToOString(aUrl2, RTL_TEXTENCODING_UTF8). 1128 getStr()); 1129 bSuccess = false; 1130 } 1131 } 1132 } 1133 1134 if (true) 1135 { 1136 struct Test 1137 { 1138 char const * m_pInput; 1139 char const * m_pOutput; 1140 }; 1141 static Test const aTest[] 1142 = { { "file:///abc", "file:///abc" }, 1143 { "file://localhost/abc", "file:///abc" }, 1144 { "file://LocalHost/abc", "file:///abc" }, 1145 { "file://LOCALHOST/abc", "file:///abc" }, 1146 { "file://127.0.0.1/abc", "file://127.0.0.1/abc" }, 1147 { "file://xxx.yyy-zzz/abc", "file://xxx.yyy-zzz/abc" }, 1148 { "file://xxx_yyy/abc", "file://xxx_yyy/abc" }, 1149 { "file://!%23$%&'()-.@^_{}~/abc", 1150 "file://!%23$%25&'()-.@%5E_%7B%7D~/abc" }, 1151 { "file://d:\\dir1\\file1", 0 }, 1152 { "http://as@alaska:8000/test/test.sxw", 0 }, 1153 { "telnet:", 0 }, 1154 { "telnet://", 0 }, 1155 { "telnet://ab:cd@ef:", "telnet://ab:cd@ef:/" }, 1156 { "telnet://ab:cd@ef:123", "telnet://ab:cd@ef:123/" }, 1157 { "TELNET://abc.def.ghi/", "telnet://abc.def.ghi/" }, 1158 { "telnet://abc.def.ghi/jkl", 0 }, 1159 { "telnet://abc.def.ghi?jkl", 0 }, 1160 { "telnet://abc.def.ghi/?jkl", 0 }, 1161 { "file:", 0 }, 1162 { "file:/", "file:///" }, 1163 { "file:/abc", "file:///abc" }, 1164 { "file:/abc/def", "file:///abc/def" }, 1165 { "file:/localhost", "file:///localhost" }, 1166 { "file://", "file:///" }, 1167 { "file:///", "file:///" }, 1168 { "http:", 0 }, 1169 { "http:/abc", 0 }, 1170 { "news:", 0 }, 1171 { "news:*", "news:*" }, 1172 { "news:**", 0 }, 1173 { "news:%2A", 0 }, 1174 { "news:a", "news:a" }, 1175 { "news:A", "news:A" }, 1176 { "news:+-._", 0 }, 1177 { "news:A0+-._", "news:A0+-._" }, 1178 { "news:0", 0 }, 1179 { "news:AB,", 0 }, 1180 { "news:abc@def", "news:abc@def" }, 1181 { "news:abc@def:33", 0 }, 1182 { "news:abc@123.456.789.0", "news:abc@123.456.789.0" }, 1183 { "news:abc@def.", "news:abc@def." }, 1184 { "news:abc@def.ghi", "news:abc@def.ghi" }, 1185 { "news:abc@def.-ghi", 0 }, 1186 { "news:abc@def.ghi@", 0 }, 1187 { "news:%21%22%23@def", "news:%21%22%23@def" }, 1188 { "news:!%22%23@def", "news:!%22%23@def" }, 1189 { "news: @def", "news:%20@def" }, 1190 { "vnd.sun.star.tdoc:", 0 }, 1191 { "vnd.sun.star.tdoc:a/b/c", 0 }, 1192 { "vnd.sun.star.tdoc:/", "vnd.sun.star.tdoc:/" }, 1193 { "vnd.sun.star.tdoc:/a;b/", "vnd.sun.star.tdoc:/a%3Bb/" }, 1194 { "vnd.sun.star.tdoc:/a?b", "vnd.sun.star.tdoc:/a%3Fb" }, 1195 { "http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/x", 1196 "http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]:80/x" }, 1197 { "http://[1080:0:0:0:8:800:200C:417A]/index.html", 1198 "http://[1080:0:0:0:8:800:200c:417a]/index.html" }, 1199 { "http://[3ffe:2a00:100:7031::1]", 1200 "http://[3ffe:2a00:100:7031::1]/" }, 1201 { "http://[1080::8:800:200c:417a]/foo", 1202 "http://[1080::8:800:200c:417a]/foo" }, 1203 { "http://[::192.9.5.5]/ipng", "http://[::192.9.5.5]/ipng" }, 1204 { "http://[:::192.9.5.5]/ipng", "http://[:::192.9.5.5]/ipng" }, 1205 { "http://[::FFFF:129.144.52.38]:80/index.html", 1206 "http://[::ffff:129.144.52.38]:80/index.html" }, 1207 { "http://[2010:836B:4179::836B:4179]", 1208 "http://[2010:836b:4179::836b:4179]/" }, 1209 { "http://[::1]", "http://[::1]/" }, 1210 { "http://[0:0:0:0:0:0:13.1.68.3]/", 1211 "http://[0:0:0:0:0:0:13.1.68.3]/" }, 1212 { "http://[0:0:0:0:0:FFFF:129.144.52.38]/", 1213 "http://[0:0:0:0:0:ffff:129.144.52.38]/" }, 1214 { "smb://", "smb:///" }, 1215 { "smb://foo", "smb://foo/" }, 1216 { "smb://x;foo:bar@baz.xyz:12345/ab?cd", 1217 "smb://x;foo:bar@baz.xyz:12345/ab?cd" } }; 1218 for (std::size_t i = 0; i < sizeof aTest / sizeof aTest[0]; ++i) 1219 { 1220 INetURLObject aUrl(aTest[i].m_pInput); 1221 if (aTest[i].m_pOutput == 0 1222 ? !aUrl.HasError() 1223 : (aUrl.HasError() 1224 || (aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI). 1225 equalsAscii(aTest[i].m_pOutput) 1226 != sal_True))) 1227 { 1228 String sTest(aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI)); 1229 printf("BAD %s -> %s != %s\n", 1230 aTest[i].m_pInput, 1231 aUrl.HasError() ? "<none>" 1232 : ByteString(sTest, RTL_TEXTENCODING_ASCII_US).GetBuffer(), 1233 aTest[i].m_pOutput == 0 ? "<none>" : aTest[i].m_pOutput); 1234 } 1235 } 1236 } 1237 1238 if (true) 1239 { 1240 struct Test 1241 { 1242 char const * m_pInput; 1243 char const * m_pOutput; 1244 }; 1245 static Test const aTest[] 1246 = { { "file://d:\\dir1\\file1", "file:///d:/dir1/file1" }, 1247 { "http://as@alaska:8000/test/test.sxw", 0 } }; 1248 for (std::size_t i = 0; i < sizeof aTest / sizeof aTest[0]; ++i) 1249 { 1250 INetURLObject aUrl = INetURLObject( 1251 String(aTest[i].m_pInput, RTL_TEXTENCODING_UTF8), 1252 INET_PROT_HTTP); 1253 if (aTest[i].m_pOutput == 0 1254 ? !aUrl.HasError() 1255 : (aUrl.HasError() 1256 || (aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI). 1257 equalsAscii(aTest[i].m_pOutput) 1258 != sal_True))) 1259 { 1260 String sTest(aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI)); 1261 printf("BAD %s -> %s != %s\n", 1262 aTest[i].m_pInput, 1263 aUrl.HasError() ? "<none>" 1264 : ByteString(sTest, RTL_TEXTENCODING_ASCII_US).GetBuffer(), 1265 aTest[i].m_pOutput == 0 ? "<none>" : aTest[i].m_pOutput); 1266 } 1267 } 1268 } 1269 1270 if (true) 1271 { 1272 INetURLObject aUrl; 1273 rtl::OUString aUser; 1274 aUrl = INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 1275 "ftp://test"))); 1276 aUser = aUrl.GetUser(); 1277 if (aUser.getLength() != 0) 1278 printf( 1279 "BAD <ftp://test> user: \"%s\" != \"\"", 1280 rtl::OUStringToOString(aUser, RTL_TEXTENCODING_UTF8).getStr()); 1281 aUrl = INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 1282 "ftp://user@test"))); 1283 aUser = aUrl.GetUser(); 1284 if (!aUser.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("user"))) 1285 printf( 1286 "BAD <ftp://user@test> user: \"%s\" != \"user\"", 1287 rtl::OUStringToOString(aUser, RTL_TEXTENCODING_UTF8).getStr()); 1288 } 1289 1290 if (true) 1291 { 1292 INetURLObject aUrl; 1293 1294 aUrl = INetURLObject("vnd.sun.star.pkg://foo.bar/a/b/c?abc/def?"); 1295 if (aUrl.GetProtocol() != INET_PROT_VND_SUN_STAR_PKG) 1296 printf("BAD <vnd.sun.star.pkg://foo.bar/a/b/c?abc/def?>:" 1297 " scheme = %d\n", 1298 static_cast< int >(aUrl.GetProtocol())); 1299 else 1300 { 1301 if (!rtl::OUString(aUrl.GetMainURL(INetURLObject::NO_DECODE)). 1302 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( 1303 "vnd.sun.star.pkg://foo.bar/a/b/c?abc/def?"))) 1304 printf("BAD <vnd.sun.star.pkg://foo.bar/a/b/c?abc/def?>:" 1305 " URL = %s\n", 1306 rtl::OUStringToOString( 1307 aUrl.GetMainURL(INetURLObject::NO_DECODE), 1308 RTL_TEXTENCODING_UTF8).getStr()); 1309 if (!rtl::OUString(aUrl.GetParam(INetURLObject::NO_DECODE)). 1310 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("abc/def?"))) 1311 printf("BAD <vnd.sun.star.pkg://foo.bar/a/b/c?abc/def?>:" 1312 " query = %s\n", 1313 rtl::OUStringToOString( 1314 aUrl.GetParam(INetURLObject::NO_DECODE), 1315 RTL_TEXTENCODING_UTF8).getStr()); 1316 } 1317 1318 aUrl = INetURLObject("vnd.sun.star.pkg://foo.bar/a/b/c%3Fabc/def%3F"); 1319 if (aUrl.GetProtocol() != INET_PROT_VND_SUN_STAR_PKG) 1320 printf("BAD <vnd.sun.star.pkg://foo.bar/a/b/c%%3Fabc/def%%3F>:" 1321 " scheme = %d\n", 1322 static_cast< int >(aUrl.GetProtocol())); 1323 else 1324 { 1325 if (!rtl::OUString(aUrl.GetMainURL(INetURLObject::NO_DECODE)). 1326 equalsAsciiL( 1327 RTL_CONSTASCII_STRINGPARAM( 1328 "vnd.sun.star.pkg://foo.bar/a/b/c%3Fabc/def%3F"))) 1329 printf("BAD <vnd.sun.star.pkg://foo.bar/a/b/c?abc/def?>:" 1330 " URL = %s\n", 1331 rtl::OUStringToOString( 1332 aUrl.GetMainURL(INetURLObject::NO_DECODE), 1333 RTL_TEXTENCODING_UTF8).getStr()); 1334 if (!rtl::OUString(aUrl.GetParam(INetURLObject::NO_DECODE)). 1335 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(""))) 1336 printf("BAD <vnd.sun.star.pkg://foo.bar/a/b/c%%3Fabc/def%%3F>:" 1337 " query = %s\n", 1338 rtl::OUStringToOString( 1339 aUrl.GetParam(INetURLObject::NO_DECODE), 1340 RTL_TEXTENCODING_UTF8).getStr()); 1341 } 1342 } 1343 1344 if (true) 1345 { 1346 struct Test 1347 { 1348 INetProtocol eScheme; 1349 char const * pPath; 1350 char const * pUri; 1351 }; 1352 static Test const aTest[] 1353 = { { INET_PROT_FILE, "", "file:///" }, 1354 { INET_PROT_FILE, "/", "file:///" }, 1355 { INET_PROT_FILE, "abc", 0 }, 1356 { INET_PROT_FILE, "/abc/", "file:///abc/" }, 1357 { INET_PROT_NEWS, "", 0 }, 1358 { INET_PROT_NEWS, "*", "news:*" }, 1359 { INET_PROT_NEWS, "**", 0 }, 1360 { INET_PROT_NEWS, "%2A", 0 }, 1361 { INET_PROT_NEWS, "a", "news:a" }, 1362 { INET_PROT_NEWS, "A", "news:A" }, 1363 { INET_PROT_NEWS, "+-._", 0 }, 1364 { INET_PROT_NEWS, "A0+-._", "news:A0+-._" }, 1365 { INET_PROT_NEWS, "0", 0 }, 1366 { INET_PROT_NEWS, "AB,", 0 }, 1367 { INET_PROT_NEWS, "abc@def", "news:abc@def" }, 1368 { INET_PROT_NEWS, "abc@def:33", 0 }, 1369 { INET_PROT_NEWS, "abc@123.456.789.0", 1370 "news:abc@123.456.789.0" }, 1371 { INET_PROT_NEWS, "abc@def.", "news:abc@def." }, 1372 { INET_PROT_NEWS, "abc@def.ghi", "news:abc@def.ghi" }, 1373 { INET_PROT_NEWS, "abc@def.-ghi", 0 }, 1374 { INET_PROT_NEWS, "abc@def.ghi@", 0 }, 1375 { INET_PROT_NEWS, "!\"#@def", "news:!%22%23@def" }, 1376 { INET_PROT_NEWS, " @def", "news:%20@def" } }; 1377 for (std::size_t i = 0; i < sizeof aTest / sizeof aTest[0]; ++i) 1378 { 1379 INetURLObject aUri; 1380 bool bOk = aUri.ConcatData(aTest[i].eScheme, String(), String(), 1381 String(), 0, 1382 String(aTest[i].pPath, 1383 RTL_TEXTENCODING_ASCII_US), 1384 INetURLObject::ENCODE_ALL); 1385 if (bOk == aUri.HasError()) 1386 printf( 1387 "BAD ConcatData(%d, ..., %s) = %d, HasError() = %d\n", 1388 static_cast< int >(aTest[i].eScheme), aTest[i].pPath, 1389 static_cast< int >(bOk), 1390 static_cast< int >(aUri.HasError())); 1391 else if (aTest[i].pUri == 0 1392 ? !aUri.HasError() 1393 : (aUri.HasError() 1394 || (aUri.GetMainURL(INetURLObject::DECODE_TO_IURI). 1395 equalsAscii(aTest[i].pUri) 1396 != sal_True))) 1397 { 1398 String sTest(aUri.GetMainURL(INetURLObject::DECODE_TO_IURI)); 1399 printf("BAD ConcatData(%d, ..., %s) -> %s != %s\n", 1400 static_cast< int >(aTest[i].eScheme), aTest[i].pPath, 1401 aUri.HasError() ? "<none>" 1402 : ByteString(sTest, RTL_TEXTENCODING_ASCII_US).GetBuffer(), 1403 aTest[i].pUri == 0 ? "<none>" : aTest[i].pUri); 1404 } 1405 } 1406 } 1407 1408 if (true) 1409 { 1410 // #i13760# 1411 1412 // Test for unrelated URLs. 1413 const rtl::OUString aBaseURL(RTL_CONSTASCII_USTRINGPARAM( 1414 "http://www.openoffice.org")); 1415 rtl::OUString aRelURL (RTL_CONSTASCII_USTRINGPARAM( 1416 "http://www.sun.com")); 1417 1418 rtl::OUString aRelURLToTest( 1419 INetURLObject::GetRelURL(aBaseURL, aRelURL)); 1420 1421 if (INetURLObject(aRelURLToTest) != INetURLObject(aRelURL)) 1422 printf("BAD GetRelURL(%s, %s), ret = %s\n", 1423 ByteString(aBaseURL.getStr(), 1424 RTL_TEXTENCODING_ASCII_US).GetBuffer(), 1425 ByteString(aRelURL.getStr(), 1426 RTL_TEXTENCODING_ASCII_US).GetBuffer(), 1427 ByteString(aRelURLToTest.getStr(), 1428 RTL_TEXTENCODING_ASCII_US).GetBuffer()); 1429 1430 // Test for related URLs. 1431 aRelURL = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 1432 "http://www.openoffice.org/api/test.html")); 1433 aRelURLToTest = rtl::OUString( 1434 INetURLObject::GetRelURL(aBaseURL, aRelURL)); 1435 1436 if (!aRelURLToTest.equalsAsciiL( 1437 RTL_CONSTASCII_STRINGPARAM("api/test.html"))) 1438 printf("BAD GetRelURL(%s, %s), ret = %s\n", 1439 ByteString(aBaseURL.getStr(), 1440 RTL_TEXTENCODING_ASCII_US).GetBuffer(), 1441 ByteString(aRelURL.getStr(), 1442 RTL_TEXTENCODING_ASCII_US).GetBuffer(), 1443 ByteString(aRelURLToTest.getStr(), 1444 RTL_TEXTENCODING_ASCII_US).GetBuffer()); 1445 } 1446 1447 if (true) { // #112130# 1448 INetURLObject url1(rtl::OUString::createFromAscii(".uno:abc%3Fdef")); 1449 if (url1.GetProtocol() != INET_PROT_UNO) { 1450 printf("BAD .uno:abc%%3Fdef\n"); 1451 bSuccess = false; 1452 } 1453 if (!rtl::OUString(url1.GetURLPath(INetURLObject::NO_DECODE)). 1454 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("abc%3Fdef"))) { 1455 printf( 1456 "BAD GetURLPath(.uno:abc%%3Fdef): %s\n", 1457 rtl::OUStringToOString( 1458 url1.GetURLPath(INetURLObject::NO_DECODE), 1459 osl_getThreadTextEncoding()).getStr()); 1460 bSuccess = false; 1461 } 1462 if (url1.HasParam()) { 1463 printf("BAD HasParam(.uno:abc%%3Fdef)\n"); 1464 bSuccess = false; 1465 } 1466 INetURLObject url2(rtl::OUString::createFromAscii(".uno:abc?def?ghi")); 1467 if (url2.GetProtocol() != INET_PROT_UNO) { 1468 printf("BAD .uno:abc?def?ghi\n"); 1469 bSuccess = false; 1470 } 1471 if (!rtl::OUString(url2.GetURLPath(INetURLObject::NO_DECODE)). 1472 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("abc"))) { 1473 printf( 1474 "BAD GetURLPath(.uno:abc?def?ghi): %s\n", 1475 rtl::OUStringToOString( 1476 url2.GetURLPath(INetURLObject::NO_DECODE), 1477 osl_getThreadTextEncoding()).getStr()); 1478 bSuccess = false; 1479 } 1480 if (!url2.HasParam()) { 1481 printf("BAD HasParam(.uno:abc?def?ghi)\n"); 1482 bSuccess = false; 1483 } 1484 if (!rtl::OUString(url2.GetParam(INetURLObject::NO_DECODE)). 1485 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("def?ghi"))) { 1486 printf( 1487 "BAD GetURLPath(.uno:abc?def?ghi): %s\n", 1488 rtl::OUStringToOString( 1489 url2.GetParam(INetURLObject::NO_DECODE), 1490 osl_getThreadTextEncoding()).getStr()); 1491 bSuccess = false; 1492 } 1493 } 1494 1495 if (true) { // #116269# 1496 rtl::OUString url; 1497 INetURLObject urlobj; 1498 1499 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("A-b.3:/%2f?x#y")); 1500 urlobj = INetURLObject(url); 1501 bSuccess &= assertEqual(url, INET_PROT_GENERIC, urlobj.GetProtocol()); 1502 bSuccess &= assertEqual( 1503 url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a-b.3:/%2F?x#y")), 1504 rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE))); 1505 bSuccess &= assertEqual(url, false, urlobj.HasUserData()); 1506 bSuccess &= assertEqual(url, false, urlobj.hasPassword()); 1507 bSuccess &= assertEqual(url, false, urlobj.HasPort()); 1508 bSuccess &= assertEqual( 1509 url, rtl::OUString(), rtl::OUString(urlobj.GetHost())); 1510 bSuccess &= assertEqual( 1511 url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/%2F?x")), 1512 rtl::OUString(urlobj.GetURLPath())); 1513 bSuccess &= assertEqual(url, false, urlobj.HasParam()); 1514 bSuccess &= assertEqual(url, true, urlobj.HasMark()); 1515 bSuccess &= assertEqual( 1516 url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("y")), 1517 rtl::OUString(urlobj.GetMark())); 1518 1519 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foo:")); 1520 urlobj = INetURLObject(url); 1521 bSuccess &= assertEqual(url, true, urlobj.HasError()); 1522 1523 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foo:#")); 1524 urlobj = INetURLObject(url); 1525 bSuccess &= assertEqual(url, true, urlobj.HasError()); 1526 1527 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foo:/")); 1528 urlobj = INetURLObject(url); 1529 bSuccess &= assertEqual(url, INET_PROT_GENERIC, urlobj.GetProtocol()); 1530 bSuccess &= assertEqual( 1531 url, url, 1532 rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE))); 1533 1534 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".foo:/")); 1535 urlobj = INetURLObject(url); 1536 bSuccess &= assertEqual(url, true, urlobj.HasError()); 1537 1538 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("C:\\bla")); 1539 urlobj = INetURLObject(url); 1540 bSuccess &= assertEqual(url, true, urlobj.HasError()); 1541 1542 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("C:\\bla")); 1543 urlobj = INetURLObject(url, INET_PROT_FILE); 1544 bSuccess &= assertEqual(url, INET_PROT_FILE, urlobj.GetProtocol()); 1545 bSuccess &= assertEqual( 1546 url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///C:/bla")), 1547 rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE))); 1548 1549 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LPR:\\bla")); 1550 urlobj = INetURLObject(url); 1551 bSuccess &= assertEqual(url, INET_PROT_GENERIC, urlobj.GetProtocol()); 1552 bSuccess &= assertEqual( 1553 url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("lpr:%5Cbla")), 1554 rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE))); 1555 1556 url = rtl::OUString( 1557 RTL_CONSTASCII_USTRINGPARAM("private:factory/swriter")); 1558 urlobj = INetURLObject(url); 1559 bSuccess &= assertEqual( 1560 url, INET_PROT_PRIV_SOFFICE, urlobj.GetProtocol()); 1561 bSuccess &= assertEqual( 1562 url, url, 1563 rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE))); 1564 1565 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("A-b.3:/%2f?x#y")); 1566 urlobj = INetURLObject(url, INET_PROT_CID); 1567 bSuccess &= assertEqual(url, INET_PROT_GENERIC, urlobj.GetProtocol()); 1568 bSuccess &= assertEqual( 1569 url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a-b.3:/%2F?x#y")), 1570 rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE))); 1571 1572 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foo:")); 1573 urlobj = INetURLObject(url, INET_PROT_CID); 1574 bSuccess &= assertEqual(url, INET_PROT_CID, urlobj.GetProtocol()); 1575 bSuccess &= assertEqual( 1576 url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cid:foo:")), 1577 rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE))); 1578 1579 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foo:#")); 1580 urlobj = INetURLObject(url, INET_PROT_CID); 1581 bSuccess &= assertEqual(url, INET_PROT_CID, urlobj.GetProtocol()); 1582 bSuccess &= assertEqual( 1583 url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cid:foo:#")), 1584 rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE))); 1585 1586 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foo:/")); 1587 urlobj = INetURLObject(url, INET_PROT_CID); 1588 bSuccess &= assertEqual(url, INET_PROT_GENERIC, urlobj.GetProtocol()); 1589 bSuccess &= assertEqual( 1590 url, url, 1591 rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE))); 1592 1593 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".foo:/")); 1594 urlobj = INetURLObject(url, INET_PROT_CID); 1595 bSuccess &= assertEqual(url, INET_PROT_CID, urlobj.GetProtocol()); 1596 bSuccess &= assertEqual( 1597 url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cid:.foo:/")), 1598 rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE))); 1599 1600 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("C:\\bla")); 1601 urlobj = INetURLObject(url, INET_PROT_CID); 1602 bSuccess &= assertEqual(url, INET_PROT_FILE, urlobj.GetProtocol()); 1603 bSuccess &= assertEqual( 1604 url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///C:/bla")), 1605 rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE))); 1606 1607 url = rtl::OUString( 1608 RTL_CONSTASCII_USTRINGPARAM("private:factory/swriter")); 1609 urlobj = INetURLObject(url, INET_PROT_CID); 1610 bSuccess &= assertEqual( 1611 url, INET_PROT_PRIV_SOFFICE, urlobj.GetProtocol()); 1612 bSuccess &= assertEqual( 1613 url, url, 1614 rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE))); 1615 1616 // #i80134#: 1617 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\\\\foobar\\%20#")); 1618 urlobj = INetURLObject(url, INET_PROT_FILE); 1619 bSuccess &= assertEqual(url, INET_PROT_FILE, urlobj.GetProtocol()); 1620 bSuccess &= assertEqual( 1621 url, 1622 rtl::OUString( 1623 RTL_CONSTASCII_USTRINGPARAM("file://foobar/%2520%23")), 1624 rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE))); 1625 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\\\\foo_bar\\%20#")); 1626 urlobj = INetURLObject(url, INET_PROT_FILE); 1627 bSuccess &= assertEqual(url, INET_PROT_FILE, urlobj.GetProtocol()); 1628 bSuccess &= assertEqual( 1629 url, 1630 rtl::OUString( 1631 RTL_CONSTASCII_USTRINGPARAM("file://foo_bar/%2520%23")), 1632 rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE))); 1633 } 1634 1635 if (true) { // #i53184# 1636 rtl::OUString url(RTL_CONSTASCII_USTRINGPARAM("file://comp_name/path")); 1637 bSuccess &= assertEqual( 1638 rtl::OUString( 1639 RTL_CONSTASCII_USTRINGPARAM("#i53184# smart INET_PROT_FILE")), 1640 INetURLObject(url, INET_PROT_FILE).GetMainURL( 1641 INetURLObject::NO_DECODE), 1642 url); 1643 bSuccess &= assertEqual( 1644 rtl::OUString( 1645 RTL_CONSTASCII_USTRINGPARAM("#i53184# strict")), 1646 INetURLObject(url).GetMainURL(INetURLObject::NO_DECODE), url); 1647 } 1648 1649 if (true) { 1650 rtl::OUString path; 1651 path = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/a/b/c")); 1652 bSuccess &= assertEqual( 1653 path, 1654 rtl::OUString( 1655 INetURLObject(path, INetURLObject::FSYS_DETECT).GetMainURL( 1656 INetURLObject::NO_DECODE)), 1657 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///a/b/c"))); 1658 path = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a\\b\\c")); 1659 bSuccess &= assertEqual( 1660 path, 1661 rtl::OUString( 1662 INetURLObject(path, INetURLObject::FSYS_DETECT).GetMainURL( 1663 INetURLObject::NO_DECODE)), 1664 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///a/b/c"))); 1665 path = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a:b:c")); 1666 bSuccess &= assertEqual( 1667 path, INetURLObject(path, INetURLObject::FSYS_DETECT).HasError(), 1668 true); 1669 bSuccess &= assertEqual( 1670 path, 1671 rtl::OUString( 1672 INetURLObject( 1673 path, 1674 INetURLObject::FSysStyle( 1675 INetURLObject::FSYS_DETECT | INetURLObject::FSYS_MAC)). 1676 GetMainURL(INetURLObject::NO_DECODE)), 1677 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///a/b/c"))); 1678 rtl::OUString url; 1679 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/a/b/c")); 1680 bSuccess &= assertEqual( 1681 url, 1682 rtl::OUString( 1683 INetURLObject(url, INET_PROT_HTTP).GetMainURL( 1684 INetURLObject::NO_DECODE)), 1685 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///a/b/c"))); 1686 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a:\\b\\c")); 1687 bSuccess &= assertEqual( 1688 url, 1689 rtl::OUString( 1690 INetURLObject(url, INET_PROT_HTTP).GetMainURL( 1691 INetURLObject::NO_DECODE)), 1692 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///a:/b/c"))); 1693 url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a:b:c")); 1694 bSuccess &= assertEqual( 1695 url, INetURLObject(url, INET_PROT_HTTP).HasError(), true); 1696 bSuccess &= assertEqual( 1697 url, 1698 (INetURLObject( 1699 url, INET_PROT_HTTP, INetURLObject::WAS_ENCODED, 1700 RTL_TEXTENCODING_UTF8, 1701 INetURLObject::FSysStyle( 1702 INetURLObject::FSYS_DETECT | INetURLObject::FSYS_MAC)). 1703 HasError()), 1704 true); 1705 } 1706 1707 bSuccess &= test_getSegmentCount("mailto:a@b", false, 0); 1708 bSuccess &= test_getSegmentCount("vnd.sun.star.expand:$PREFIX", false, 1); 1709 bSuccess &= test_getSegmentCount("vnd.sun.star.expand:$PREFIX", true, 1); 1710 bSuccess &= test_getSegmentCount("vnd.sun.star.expand:$PREFIX/", false, 2); 1711 bSuccess &= test_getSegmentCount("vnd.sun.star.expand:$PREFIX/", true, 1); 1712 bSuccess &= test_getSegmentCount( 1713 "vnd.sun.star.expand:$PREFIX/foo", false, 2); 1714 bSuccess &= test_getSegmentCount( 1715 "vnd.sun.star.expand:$PREFIX/foo", true, 2); 1716 bSuccess &= test_getSegmentCount("file:///", false, 1); 1717 bSuccess &= test_getSegmentCount("file:///", true, 0); 1718 bSuccess &= test_getSegmentCount("file:///foo", false, 1); 1719 bSuccess &= test_getSegmentCount("file:///foo", true, 1); 1720 1721 bSuccess &= test_insertName( 1722 "mailto:a@b", "foo", false, 0, false, false, "mailto:a@b"); 1723 bSuccess &= test_insertName( 1724 "vnd.sun.star.expand:$PREFIX", "foo", false, 0, false, true, 1725 "vnd.sun.star.expand:%2Ffoo/$PREFIX"); 1726 bSuccess &= test_insertName( 1727 "vnd.sun.star.expand:$PREFIX", "foo", false, 0, true, true, 1728 "vnd.sun.star.expand:%2Ffoo/$PREFIX"); 1729 bSuccess &= test_insertName( 1730 "vnd.sun.star.expand:$PREFIX", "foo", true, 0, false, true, 1731 "vnd.sun.star.expand:%2Ffoo/$PREFIX"); 1732 bSuccess &= test_insertName( 1733 "vnd.sun.star.expand:$PREFIX", "foo", true, 0, true, true, 1734 "vnd.sun.star.expand:%2Ffoo/$PREFIX"); 1735 bSuccess &= test_insertName( 1736 "vnd.sun.star.expand:$PREFIX", "foo", false, 1, false, true, 1737 "vnd.sun.star.expand:$PREFIX/foo"); 1738 bSuccess &= test_insertName( 1739 "vnd.sun.star.expand:$PREFIX", "foo", false, 1, true, true, 1740 "vnd.sun.star.expand:$PREFIX/foo"); 1741 bSuccess &= test_insertName( 1742 "vnd.sun.star.expand:$PREFIX", "foo", true, 1, false, true, 1743 "vnd.sun.star.expand:$PREFIX/foo/"); 1744 bSuccess &= test_insertName( 1745 "vnd.sun.star.expand:$PREFIX", "foo", true, 1, true, true, 1746 "vnd.sun.star.expand:$PREFIX/foo/"); 1747 bSuccess &= test_insertName( 1748 "vnd.sun.star.expand:$PREFIX", "foo", false, 1749 INetURLObject::LAST_SEGMENT, false, true, 1750 "vnd.sun.star.expand:$PREFIX/foo"); 1751 bSuccess &= test_insertName( 1752 "vnd.sun.star.expand:$PREFIX", "foo", false, 1753 INetURLObject::LAST_SEGMENT, true, true, 1754 "vnd.sun.star.expand:$PREFIX/foo"); 1755 bSuccess &= test_insertName( 1756 "vnd.sun.star.expand:$PREFIX", "foo", true, 1757 INetURLObject::LAST_SEGMENT, false, true, 1758 "vnd.sun.star.expand:$PREFIX/foo/"); 1759 bSuccess &= test_insertName( 1760 "vnd.sun.star.expand:$PREFIX", "foo", true, 1761 INetURLObject::LAST_SEGMENT, true, true, 1762 "vnd.sun.star.expand:$PREFIX/foo/"); 1763 bSuccess &= test_insertName( 1764 "vnd.sun.star.expand:$PREFIX/", "foo", false, 1765 1, false, true, 1766 "vnd.sun.star.expand:$PREFIX/foo/"); 1767 bSuccess &= test_insertName( 1768 "vnd.sun.star.expand:$PREFIX/", "foo", false, 1769 1, true, true, 1770 "vnd.sun.star.expand:$PREFIX/foo"); 1771 bSuccess &= test_insertName( 1772 "vnd.sun.star.expand:$PREFIX/", "foo", true, 1773 1, false, true, 1774 "vnd.sun.star.expand:$PREFIX/foo/"); 1775 bSuccess &= test_insertName( 1776 "vnd.sun.star.expand:$PREFIX/", "foo", true, 1777 1, true, true, 1778 "vnd.sun.star.expand:$PREFIX/foo/"); 1779 bSuccess &= test_insertName( 1780 "vnd.sun.star.expand:$PREFIX/", "foo", false, 1781 INetURLObject::LAST_SEGMENT, false, true, 1782 "vnd.sun.star.expand:$PREFIX//foo"); 1783 bSuccess &= test_insertName( 1784 "vnd.sun.star.expand:$PREFIX/", "foo", false, 1785 INetURLObject::LAST_SEGMENT, true, true, 1786 "vnd.sun.star.expand:$PREFIX/foo"); 1787 bSuccess &= test_insertName( 1788 "vnd.sun.star.expand:$PREFIX/", "foo", true, 1789 INetURLObject::LAST_SEGMENT, false, true, 1790 "vnd.sun.star.expand:$PREFIX//foo/"); 1791 bSuccess &= test_insertName( 1792 "vnd.sun.star.expand:$PREFIX/", "foo", true, 1793 INetURLObject::LAST_SEGMENT, true, true, 1794 "vnd.sun.star.expand:$PREFIX/foo/"); 1795 bSuccess &= test_insertName( 1796 "file:///", "foo", false, 0, false, true, "file:///foo/"); 1797 bSuccess &= test_insertName( 1798 "file:///", "foo", false, 0, true, true, "file:///foo"); 1799 bSuccess &= test_insertName( 1800 "file:///", "foo", true, 0, false, true, "file:///foo/"); 1801 bSuccess &= test_insertName( 1802 "file:///", "foo", true, 0, true, true, "file:///foo/"); 1803 bSuccess &= test_insertName( 1804 "file:///bar", "foo", false, 0, false, true, "file:///foo/bar"); 1805 bSuccess &= test_insertName( 1806 "file:///bar", "foo", false, 0, true, true, "file:///foo/bar"); 1807 bSuccess &= test_insertName( 1808 "file:///bar", "foo", true, 0, false, true, "file:///foo/bar"); 1809 bSuccess &= test_insertName( 1810 "file:///bar", "foo", true, 0, true, true, "file:///foo/bar"); 1811 1812 bSuccess &= test_removeSegment("mailto:a@b", 0, false, false, "mailto:a@b"); 1813 bSuccess &= test_removeSegment( 1814 "vnd.sun.star.expand:$PREFIX", 0, false, false, 1815 "vnd.sun.star.expand:$PREFIX"); 1816 bSuccess &= test_removeSegment( 1817 "vnd.sun.star.expand:$PREFIX", 0, true, true, 1818 "vnd.sun.star.expand:%2F"); 1819 bSuccess &= test_removeSegment( 1820 "vnd.sun.star.expand:$PREFIX", 1, false, false, 1821 "vnd.sun.star.expand:$PREFIX"); 1822 bSuccess &= test_removeSegment( 1823 "vnd.sun.star.expand:$PREFIX", 1, true, false, 1824 "vnd.sun.star.expand:$PREFIX"); 1825 bSuccess &= test_removeSegment( 1826 "vnd.sun.star.expand:$PREFIX", 2, false, false, 1827 "vnd.sun.star.expand:$PREFIX"); 1828 bSuccess &= test_removeSegment( 1829 "vnd.sun.star.expand:$PREFIX", 2, true, false, 1830 "vnd.sun.star.expand:$PREFIX"); 1831 bSuccess &= test_removeSegment( 1832 "vnd.sun.star.expand:$PREFIX", INetURLObject::LAST_SEGMENT, false, 1833 false, "vnd.sun.star.expand:$PREFIX"); 1834 bSuccess &= test_removeSegment( 1835 "vnd.sun.star.expand:$PREFIX", INetURLObject::LAST_SEGMENT, true, true, 1836 "vnd.sun.star.expand:%2F"); 1837 bSuccess &= test_removeSegment( 1838 "vnd.sun.star.expand:$PREFIX/", 0, false, true, 1839 "vnd.sun.star.expand:%2F"); 1840 bSuccess &= test_removeSegment( 1841 "vnd.sun.star.expand:$PREFIX/", 0, true, true, 1842 "vnd.sun.star.expand:%2F"); 1843 bSuccess &= test_removeSegment( 1844 "vnd.sun.star.expand:$PREFIX/", 1, false, true, 1845 "vnd.sun.star.expand:$PREFIX"); 1846 bSuccess &= test_removeSegment( 1847 "vnd.sun.star.expand:$PREFIX/", 1, true, true, 1848 "vnd.sun.star.expand:$PREFIX/"); 1849 bSuccess &= test_removeSegment( 1850 "vnd.sun.star.expand:$PREFIX/", 2, false, false, 1851 "vnd.sun.star.expand:$PREFIX/"); 1852 bSuccess &= test_removeSegment( 1853 "vnd.sun.star.expand:$PREFIX/", 2, true, false, 1854 "vnd.sun.star.expand:$PREFIX/"); 1855 bSuccess &= test_removeSegment( 1856 "vnd.sun.star.expand:$PREFIX/", INetURLObject::LAST_SEGMENT, false, 1857 true, "vnd.sun.star.expand:$PREFIX"); 1858 bSuccess &= test_removeSegment( 1859 "vnd.sun.star.expand:$PREFIX/", INetURLObject::LAST_SEGMENT, true, 1860 true, "vnd.sun.star.expand:%2F"); 1861 bSuccess &= test_removeSegment("file:///", 0, false, true, "file:///"); 1862 bSuccess &= test_removeSegment("file:///", 0, true, true, "file:///"); 1863 bSuccess &= test_removeSegment("file:///", 1, false, false, "file:///"); 1864 bSuccess &= test_removeSegment("file:///", 1, true, false, "file:///"); 1865 bSuccess &= test_removeSegment("file:///", 2, false, false, "file:///"); 1866 bSuccess &= test_removeSegment("file:///", 2, true, false, "file:///"); 1867 bSuccess &= test_removeSegment( 1868 "file:///", INetURLObject::LAST_SEGMENT, false, true, "file:///"); 1869 bSuccess &= test_removeSegment( 1870 "file:///", INetURLObject::LAST_SEGMENT, true, false, "file:///"); 1871 bSuccess &= test_removeSegment("file:///foo", 0, false, true, "file:///"); 1872 bSuccess &= test_removeSegment("file:///foo", 0, true, true, "file:///"); 1873 bSuccess &= test_removeSegment( 1874 "file:///foo", 1, false, false, "file:///foo"); 1875 bSuccess &= test_removeSegment( 1876 "file:///foo", 1, true, false, "file:///foo"); 1877 bSuccess &= test_removeSegment( 1878 "file:///foo", 2, false, false, "file:///foo"); 1879 bSuccess &= test_removeSegment( 1880 "file:///foo", 2, true, false, "file:///foo"); 1881 bSuccess &= test_removeSegment( 1882 "file:///foo", INetURLObject::LAST_SEGMENT, false, true, "file:///"); 1883 bSuccess &= test_removeSegment( 1884 "file:///foo", INetURLObject::LAST_SEGMENT, true, true, "file:///"); 1885 bSuccess &= test_removeSegment("file:///foo/", 0, false, true, "file:///"); 1886 bSuccess &= test_removeSegment("file:///foo/", 0, true, true, "file:///"); 1887 bSuccess &= test_removeSegment( 1888 "file:///foo/", 1, false, true, "file:///foo"); 1889 bSuccess &= test_removeSegment( 1890 "file:///foo/", 1, true, true, "file:///foo/"); 1891 bSuccess &= test_removeSegment( 1892 "file:///foo/", 2, false, false, "file:///foo/"); 1893 bSuccess &= test_removeSegment( 1894 "file:///foo/", 2, true, false, "file:///foo/"); 1895 bSuccess &= test_removeSegment( 1896 "file:///foo/", INetURLObject::LAST_SEGMENT, false, true, 1897 "file:///foo"); 1898 bSuccess &= test_removeSegment( 1899 "file:///foo/", INetURLObject::LAST_SEGMENT, true, true, "file:///"); 1900 1901 return bSuccess ? EXIT_SUCCESS : EXIT_FAILURE; 1902 } 1903