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