Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / stoc / test / uriproc / test_uriproc.cxx
blobaa96e6a86bf8be4f48eed38856e0cb3bdf33fa03
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/lang/XComponent.hpp>
21 #include <com/sun/star/uno/Reference.hxx>
22 #include <com/sun/star/uno/XComponentContext.hpp>
23 #include <com/sun/star/uri/ExternalUriReferenceTranslator.hpp>
24 #include <com/sun/star/uri/UriReferenceFactory.hpp>
25 #include <com/sun/star/uri/VndSunStarPkgUrlReferenceFactory.hpp>
26 #include <com/sun/star/uri/XExternalUriReferenceTranslator.hpp>
27 #include <com/sun/star/uri/XUriReference.hpp>
28 #include <com/sun/star/uri/XUriReferenceFactory.hpp>
29 #include <com/sun/star/uri/XVndSunStarExpandUrlReference.hpp>
30 #include <com/sun/star/uri/XVndSunStarPkgUrlReferenceFactory.hpp>
31 #include <com/sun/star/uri/XVndSunStarScriptUrlReference.hpp>
32 #include <com/sun/star/util/XMacroExpander.hpp>
33 #include <cppuhelper/bootstrap.hxx>
34 #include <cppunit/TestAssert.h>
35 #include <cppunit/TestFixture.h>
36 #include <cppunit/extensions/HelperMacros.h>
37 #include <cppunit/plugin/TestPlugIn.h>
38 #include <rtl/string.hxx>
39 #include <rtl/textenc.h>
40 #include <rtl/uri.hxx>
41 #include <rtl/ustrbuf.hxx>
42 #include <rtl/ustring.hxx>
43 #include <sal/types.h>
44 #include <sal/macros.h>
46 namespace {
48 #define TEST_ASSERT_EQUAL(token1, token2, token3, expected, actual) \
49 CPPUNIT_ASSERT_EQUAL_MESSAGE( \
50 createTestAssertEqualMessage( \
51 token1, token2, token3, #expected, #actual, expected, actual). \
52 getStr(), \
53 (expected), (actual))
55 template< typename T > void append(
56 OUStringBuffer & buffer, T const & value)
58 buffer.append(value);
61 template<> void append(OUStringBuffer & buffer, bool const & value) {
62 buffer.append(value);
65 template<> void append(OUStringBuffer & buffer, std::size_t const & value)
67 buffer.append(static_cast< sal_Int32 >(value));
70 template<> void append(OUStringBuffer & buffer, char const * const & value)
72 buffer.appendAscii(value);
75 template< typename T1, typename T2, typename T3, typename T4 >
76 OString createTestAssertEqualMessage(
77 char const * token1, T1 const & token2, T2 const & token3,
78 char const * expectedExpr, char const * actualExpr, T3 const & expected,
79 T4 const & actual)
81 OUStringBuffer buf(512);
82 buf.appendAscii(token1);
83 buf.append('|');
84 append(buf, token2);
85 buf.append('|');
86 append(buf, token3);
87 buf.append(": TEST_ASSERT_EQUAL(");
88 buf.appendAscii(expectedExpr);
89 buf.append(", ");
90 buf.appendAscii(actualExpr);
91 buf.append("): <");
92 append(buf, expected);
93 buf.append("> != <");
94 append(buf, actual);
95 buf.append('>');
96 return OUStringToOString(
97 buf.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US);
100 class Test: public CppUnit::TestFixture {
101 public:
102 virtual void setUp();
104 virtual void tearDown();
106 void testParse();
108 void testMakeAbsolute();
110 void testMakeRelative();
112 void testVndSunStarExpand();
114 void testVndSunStarScript();
116 void testTranslator();
118 void testPkgUrlFactory();
120 CPPUNIT_TEST_SUITE(Test);
121 CPPUNIT_TEST(testParse);
122 CPPUNIT_TEST(testMakeAbsolute);
123 CPPUNIT_TEST(testMakeRelative);
124 CPPUNIT_TEST(testVndSunStarExpand);
125 CPPUNIT_TEST(testVndSunStarScript);
126 CPPUNIT_TEST(testTranslator);
127 CPPUNIT_TEST(testPkgUrlFactory);
128 CPPUNIT_TEST_SUITE_END();
130 private:
131 css::uno::Reference< css::uno::XComponentContext > m_context;
132 css::uno::Reference< css::uri::XUriReferenceFactory > m_uriFactory;
135 void Test::setUp() {
136 m_context = cppu::defaultBootstrap_InitialComponentContext();
137 m_uriFactory = css::uri::UriReferenceFactory::create(m_context);
140 void Test::tearDown() {
141 m_uriFactory.clear();
142 css::uno::Reference< css::lang::XComponent >(
143 m_context, css::uno::UNO_QUERY_THROW)->dispose();
146 void Test::testParse() {
147 struct Data {
148 char const * uriReference;
149 char const * scheme;
150 char const * schemeSpecificPart;
151 bool isHierarchical;
152 char const * authority;
153 char const * path;
154 bool hasRelativePath;
155 sal_Int32 pathSegmentCount;
156 char const * pathSegment0;
157 char const * pathSegment1;
158 char const * pathSegment2;
159 char const * pathSegment3;
160 char const * pathSegment4;
161 char const * query;
162 char const * fragment;
164 Data data[] = {
165 { "", nullptr, "", true, nullptr,
166 "", true, 0, "", "", "", "", "", nullptr, nullptr },
167 { "scheme:", "scheme", "", false, nullptr,
168 "", true, 0, "", "", "", "", "", nullptr, nullptr },
169 { "scheme:/", "scheme", "/", true, nullptr,
170 "/", false, 1, "", "", "", "", "", nullptr, nullptr },
171 { "scheme://", "scheme", "//", true, "",
172 "", false, 0, "", "", "", "", "", nullptr, nullptr },
173 { "scheme:///", "scheme", "///", true, "",
174 "/", false, 1, "", "", "", "", "", nullptr, nullptr },
175 { "scheme:////", "scheme", "////", true, "",
176 "//", false, 2, "", "", "", "", "", nullptr, nullptr },
177 { "scheme:////", "scheme", "////", true, "",
178 "//", false, 2, "", "", "", "", "", nullptr, nullptr },
179 { "scheme:#", "scheme", "", false, nullptr,
180 "", true, 0, "", "", "", "", "", nullptr, "" },
181 { "scheme:?", "scheme", "?", false, nullptr,
182 "", true, 0, "", "", "", "", "", "", nullptr },
183 { "/", nullptr, "/", true, nullptr,
184 "/", false, 1, "", "", "", "", "", nullptr, nullptr },
185 { "//", nullptr, "//", true, "",
186 "", false, 0, "", "", "", "", "", nullptr, nullptr },
187 { "///", nullptr, "///", true, "",
188 "/", false, 1, "", "", "", "", "", nullptr, nullptr },
189 { "////", nullptr, "////", true, "",
190 "//", false, 2, "", "", "", "", "", nullptr, nullptr } };
191 for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
192 css::uno::Reference< css::uri::XUriReference > uriRef(
193 m_uriFactory->parse(
194 OUString::createFromAscii(data[i].uriReference)));
195 TEST_ASSERT_EQUAL(
196 "testParse", i, data[i].uriReference, data[i].schemeSpecificPart != nullptr,
197 uriRef.is());
198 if (uriRef.is()) {
199 TEST_ASSERT_EQUAL(
200 "testParse", i, data[i].uriReference,
201 OUString::createFromAscii(data[i].uriReference),
202 uriRef->getUriReference());
203 TEST_ASSERT_EQUAL(
204 "testParse", i, data[i].uriReference,
205 data[i].scheme != nullptr, bool(uriRef->isAbsolute()));
206 TEST_ASSERT_EQUAL(
207 "testParse", i, data[i].uriReference,
208 OUString::createFromAscii(
209 data[i].scheme == nullptr ? "" : data[i].scheme),
210 uriRef->getScheme());
211 TEST_ASSERT_EQUAL(
212 "testParse", i, data[i].uriReference,
213 OUString::createFromAscii(data[i].schemeSpecificPart),
214 uriRef->getSchemeSpecificPart());
215 TEST_ASSERT_EQUAL(
216 "testParse", i, data[i].uriReference,
217 data[i].isHierarchical,
218 static_cast< bool >(uriRef->isHierarchical()));
219 TEST_ASSERT_EQUAL(
220 "testParse", i, data[i].uriReference,
221 data[i].authority != nullptr, bool(uriRef->hasAuthority()));
222 TEST_ASSERT_EQUAL(
223 "testParse", i, data[i].uriReference,
224 OUString::createFromAscii(
225 data[i].authority == nullptr ? "" : data[i].authority),
226 uriRef->getAuthority());
227 TEST_ASSERT_EQUAL(
228 "testParse", i, data[i].uriReference,
229 OUString::createFromAscii(data[i].path),
230 uriRef->getPath());
231 TEST_ASSERT_EQUAL(
232 "testParse", i, data[i].uriReference,
233 data[i].hasRelativePath,
234 static_cast< bool >(uriRef->hasRelativePath()));
235 TEST_ASSERT_EQUAL(
236 "testParse", i, data[i].uriReference,
237 data[i].pathSegmentCount, uriRef->getPathSegmentCount());
238 TEST_ASSERT_EQUAL(
239 "testParse", i, data[i].uriReference,
240 OUString(), uriRef->getPathSegment(-1));
241 TEST_ASSERT_EQUAL(
242 "testParse", i, data[i].uriReference,
243 OUString::createFromAscii(data[i].pathSegment0),
244 uriRef->getPathSegment(0));
245 TEST_ASSERT_EQUAL(
246 "testParse", i, data[i].uriReference,
247 OUString::createFromAscii(data[i].pathSegment1),
248 uriRef->getPathSegment(1));
249 TEST_ASSERT_EQUAL(
250 "testParse", i, data[i].uriReference,
251 OUString::createFromAscii(data[i].pathSegment2),
252 uriRef->getPathSegment(2));
253 TEST_ASSERT_EQUAL(
254 "testParse", i, data[i].uriReference,
255 OUString::createFromAscii(data[i].pathSegment3),
256 uriRef->getPathSegment(3));
257 TEST_ASSERT_EQUAL(
258 "testParse", i, data[i].uriReference,
259 OUString::createFromAscii(data[i].pathSegment4),
260 uriRef->getPathSegment(4));
261 TEST_ASSERT_EQUAL(
262 "testParse", i, data[i].uriReference,
263 OUString(), uriRef->getPathSegment(5));
264 TEST_ASSERT_EQUAL(
265 "testParse", i, data[i].uriReference,
266 data[i].query != nullptr, bool(uriRef->hasQuery()));
267 TEST_ASSERT_EQUAL(
268 "testParse", i, data[i].uriReference,
269 OUString::createFromAscii(
270 data[i].query == nullptr ? "" : data[i].query),
271 uriRef->getQuery());
272 TEST_ASSERT_EQUAL(
273 "testParse", i, data[i].uriReference,
274 data[i].fragment != nullptr, bool(uriRef->hasFragment()));
275 TEST_ASSERT_EQUAL(
276 "testParse", i, data[i].uriReference,
277 OUString::createFromAscii(
278 data[i].fragment == nullptr ? "" : data[i].fragment),
279 uriRef->getFragment());
284 void Test::testMakeAbsolute() {
285 struct Data {
286 char const * baseUriReference;
287 char const * uriReference;
288 bool processSpecialBaseSegments;
289 css::uri::RelativeUriExcessParentSegments excessParentSegments;
290 char const * absolute;
292 Data data[] = {
293 // The following tests are taken from RFC 3986, Section 5.4:
294 { "http://a/b/c/d;p?q", "g:h", true,
295 css::uri::RelativeUriExcessParentSegments_REMOVE, "g:h" },
296 { "http://a/b/c/d;p?q", "g", true,
297 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/b/c/g" },
298 { "http://a/b/c/d;p?q", "./g", true,
299 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/b/c/g" },
300 { "http://a/b/c/d;p?q", "g/", true,
301 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/b/c/g/" },
302 { "http://a/b/c/d;p?q", "/g", true,
303 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/g" },
304 { "http://a/b/c/d;p?q", "//g", true,
305 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://g" },
306 { "http://a/b/c/d;p?q", "?y", true,
307 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/b/c/d;p?y" },
308 { "http://a/b/c/d;p?q", "g?y", true,
309 css::uri::RelativeUriExcessParentSegments_REMOVE,
310 "http://a/b/c/g?y" },
311 { "http://a/b/c/d;p?q", "#s", true,
312 css::uri::RelativeUriExcessParentSegments_REMOVE,
313 "http://a/b/c/d;p?q#s" },
314 { "http://a/b/c/d;p?q", "g#s", true,
315 css::uri::RelativeUriExcessParentSegments_REMOVE,
316 "http://a/b/c/g#s" },
317 { "http://a/b/c/d;p?q", "g?y#s", true,
318 css::uri::RelativeUriExcessParentSegments_REMOVE,
319 "http://a/b/c/g?y#s" },
320 { "http://a/b/c/d;p?q", ";x", true,
321 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/b/c/;x" },
322 { "http://a/b/c/d;p?q", "g;x", true,
323 css::uri::RelativeUriExcessParentSegments_REMOVE,
324 "http://a/b/c/g;x" },
325 { "http://a/b/c/d;p?q", "g;x?y#s", true,
326 css::uri::RelativeUriExcessParentSegments_REMOVE,
327 "http://a/b/c/g;x?y#s" },
328 { "http://a/b/c/d;p?q", "", true,
329 css::uri::RelativeUriExcessParentSegments_REMOVE,
330 "http://a/b/c/d;p?q" },
331 { "http://a/b/c/d;p?q", ".", true,
332 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/b/c/" },
333 { "http://a/b/c/d;p?q", "./", true,
334 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/b/c/" },
335 { "http://a/b/c/d;p?q", "..", true,
336 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/b/" },
337 { "http://a/b/c/d;p?q", "../", true,
338 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/b/" },
339 { "http://a/b/c/d;p?q", "../g", true,
340 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/b/g" },
341 { "http://a/b/c/d;p?q", "../..", true,
342 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/" },
343 { "http://a/b/c/d;p?q", "../../", true,
344 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/" },
345 { "http://a/b/c/d;p?q", "../../g", true,
346 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/g" },
347 { "http://a/b/c/d;p?q", "../../../g", true,
348 css::uri::RelativeUriExcessParentSegments_ERROR, nullptr },
349 { "http://a/b/c/d;p?q", "../../../g", true,
350 css::uri::RelativeUriExcessParentSegments_RETAIN, "http://a/../g" },
351 { "http://a/b/c/d;p?q", "../../../g", true,
352 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/g" },
353 { "http://a/b/c/d;p?q", "../../../../g", true,
354 css::uri::RelativeUriExcessParentSegments_ERROR, nullptr },
355 { "http://a/b/c/d;p?q", "../../../../g", true,
356 css::uri::RelativeUriExcessParentSegments_RETAIN,
357 "http://a/../../g" },
358 { "http://a/b/c/d;p?q", "../../../../g", true,
359 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/g" },
360 { "http://a/b/c/d;p?q", "/./g", true,
361 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/g" },
362 { "http://a/b/c/d;p?q", "/../g", true,
363 css::uri::RelativeUriExcessParentSegments_ERROR, nullptr },
364 { "http://a/b/c/d;p?q", "/../g", true,
365 css::uri::RelativeUriExcessParentSegments_RETAIN, "http://a/../g" },
366 { "http://a/b/c/d;p?q", "/../g", true,
367 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/g" },
368 { "http://a/b/c/d;p?q", "g.", true,
369 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/b/c/g." },
370 { "http://a/b/c/d;p?q", ".g", true,
371 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/b/c/.g" },
372 { "http://a/b/c/d;p?q", "g..", true,
373 css::uri::RelativeUriExcessParentSegments_REMOVE,
374 "http://a/b/c/g.." },
375 { "http://a/b/c/d;p?q", "..g", true,
376 css::uri::RelativeUriExcessParentSegments_REMOVE,
377 "http://a/b/c/..g" },
378 { "http://a/b/c/d;p?q", "./../g", true,
379 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/b/g" },
380 { "http://a/b/c/d;p?q", "./g/.", true,
381 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/b/c/g/" },
382 { "http://a/b/c/d;p?q", "g/./h", true,
383 css::uri::RelativeUriExcessParentSegments_REMOVE,
384 "http://a/b/c/g/h" },
385 { "http://a/b/c/d;p?q", "g/../h", true,
386 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/b/c/h" },
387 { "http://a/b/c/d;p?q", "g;x=1/./y", true,
388 css::uri::RelativeUriExcessParentSegments_REMOVE,
389 "http://a/b/c/g;x=1/y" },
390 { "http://a/b/c/d;p?q", "g;x=1/../y", true,
391 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/b/c/y" },
392 { "http://a/b/c/d;p?q", "g?y/./x", true,
393 css::uri::RelativeUriExcessParentSegments_REMOVE,
394 "http://a/b/c/g?y/./x" },
395 { "http://a/b/c/d;p?q", "g?y/../x", true,
396 css::uri::RelativeUriExcessParentSegments_REMOVE,
397 "http://a/b/c/g?y/../x" },
398 { "http://a/b/c/d;p?q", "g#s/./x", true,
399 css::uri::RelativeUriExcessParentSegments_REMOVE,
400 "http://a/b/c/g#s/./x" },
401 { "http://a/b/c/d;p?q", "g#s/../x", true,
402 css::uri::RelativeUriExcessParentSegments_REMOVE,
403 "http://a/b/c/g#s/../x" },
404 { "http://a/b/c/d;p?q", "http:g", true,
405 css::uri::RelativeUriExcessParentSegments_REMOVE, "http:g" },
407 { "scheme:", "", true,
408 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:" },
409 { "scheme:", ".", true,
410 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:" },
411 { "scheme:", "./", true,
412 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:" },
413 { "scheme:", "./.", true,
414 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:" },
415 { "scheme:", "././", true,
416 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:" },
417 { "scheme:", "././.", true,
418 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:" },
419 { "scheme:", "x/..", true,
420 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
421 { "scheme:", "x/../", true,
422 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
423 { "scheme:", "x/../.", true,
424 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
425 { "scheme:", "x/.././", true,
426 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
427 { "scheme:", "x/.././.", true,
428 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
429 { "scheme:", "x/../././", true,
430 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
431 { "scheme:", "x/../././.", true,
432 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
433 { "scheme:", "./x/..", true,
434 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
435 { "scheme:", "././x/..", true,
436 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
437 { "scheme:", "./././x/..", true,
438 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
439 { "scheme:", "./x/../.", true,
440 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
441 { "scheme:", "./x/.././", true,
442 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
443 { "scheme:", "././x/.././.", true,
444 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
445 { "scheme:", "././x/../././", true,
446 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
447 { "scheme:", "./././x/../././.", true,
448 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
450 { "scheme://a", "", true,
451 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a" },
452 { "scheme://a", ".", true,
453 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
454 { "scheme://a", "./", true,
455 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
456 { "scheme://a", "./.", true,
457 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
458 { "scheme://a", "././", true,
459 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
460 { "scheme://a", "././.", true,
461 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
462 { "scheme://a", "x/..", true,
463 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
464 { "scheme://a", "x/../", true,
465 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
466 { "scheme://a", "x/../.", true,
467 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
468 { "scheme://a", "x/.././", true,
469 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
470 { "scheme://a", "x/.././.", true,
471 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
472 { "scheme://a", "x/../././", true,
473 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
474 { "scheme://a", "x/../././.", true,
475 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
476 { "scheme://a", "./x/..", true,
477 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
478 { "scheme://a", "././x/..", true,
479 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
480 { "scheme://a", "./././x/..", true,
481 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
482 { "scheme://a", "./x/../.", true,
483 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
484 { "scheme://a", "./x/.././", true,
485 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
486 { "scheme://a", "././x/.././.", true,
487 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
488 { "scheme://a", "././x/../././", true,
489 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
490 { "scheme://a", "./././x/../././.", true,
491 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
493 { "scheme://a/", "", true,
494 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
495 { "scheme://a/", ".", true,
496 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
497 { "scheme://a/", "./", true,
498 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
499 { "scheme://a/", "./.", true,
500 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
501 { "scheme://a/", "././", true,
502 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
503 { "scheme://a/", "././.", true,
504 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
505 { "scheme://a/", "x/..", true,
506 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
507 { "scheme://a/", "x/../", true,
508 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
509 { "scheme://a/", "x/../.", true,
510 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
511 { "scheme://a/", "x/.././", true,
512 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
513 { "scheme://a/", "x/.././.", true,
514 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
515 { "scheme://a/", "x/../././", true,
516 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
517 { "scheme://a/", "x/../././.", true,
518 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
519 { "scheme://a/", "./x/..", true,
520 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
521 { "scheme://a/", "././x/..", true,
522 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
523 { "scheme://a/", "./././x/..", true,
524 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
525 { "scheme://a/", "./x/../.", true,
526 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
527 { "scheme://a/", "./x/.././", true,
528 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
529 { "scheme://a/", "././x/.././.", true,
530 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
531 { "scheme://a/", "././x/../././", true,
532 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
533 { "scheme://a/", "./././x/../././.", true,
534 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
536 { "scheme://a/b", "", true,
537 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b" },
538 { "scheme://a/b", ".", true,
539 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
540 { "scheme://a/b", "./", true,
541 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
542 { "scheme://a/b", "./.", true,
543 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
544 { "scheme://a/b", "././", true,
545 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
546 { "scheme://a/b", "././.", true,
547 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
548 { "scheme://a/b", "x/..", true,
549 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
550 { "scheme://a/b", "x/../", true,
551 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
552 { "scheme://a/b", "x/../.", true,
553 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
554 { "scheme://a/b", "x/.././", true,
555 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
556 { "scheme://a/b", "x/.././.", true,
557 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
558 { "scheme://a/b", "x/../././", true,
559 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
560 { "scheme://a/b", "x/../././.", true,
561 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
562 { "scheme://a/b", "./x/..", true,
563 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
564 { "scheme://a/b", "././x/..", true,
565 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
566 { "scheme://a/b", "./././x/..", true,
567 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
568 { "scheme://a/b", "./x/../.", true,
569 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
570 { "scheme://a/b", "./x/.././", true,
571 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
572 { "scheme://a/b", "././x/.././.", true,
573 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
574 { "scheme://a/b", "././x/../././", true,
575 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
576 { "scheme://a/b", "./././x/../././.", true,
577 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/" },
579 { "scheme://a/b/", "", true,
580 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b/" },
581 { "scheme://a/b/", ".", true,
582 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b/" },
583 { "scheme://a/b/", "./", true,
584 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b/" },
585 { "scheme://a/b/", "./.", true,
586 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b/" },
587 { "scheme://a/b/", "././", true,
588 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b/" },
589 { "scheme://a/b/", "././.", true,
590 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b/" },
591 { "scheme://a/b/", "x/..", true,
592 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b/" },
593 { "scheme://a/b/", "x/../", true,
594 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b/" },
595 { "scheme://a/b/", "x/../.", true,
596 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b/" },
597 { "scheme://a/b/", "x/.././", true,
598 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b/" },
599 { "scheme://a/b/", "x/.././.", true,
600 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b/" },
601 { "scheme://a/b/", "x/../././", true,
602 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b/" },
603 { "scheme://a/b/", "x/../././.", true,
604 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b/" },
605 { "scheme://a/b/", "./x/..", true,
606 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b/" },
607 { "scheme://a/b/", "././x/..", true,
608 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b/" },
609 { "scheme://a/b/", "./././x/..", true,
610 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b/" },
611 { "scheme://a/b/", "./x/../.", true,
612 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b/" },
613 { "scheme://a/b/", "./x/.././", true,
614 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b/" },
615 { "scheme://a/b/", "././x/.././.", true,
616 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b/" },
617 { "scheme://a/b/", "././x/../././", true,
618 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b/" },
619 { "scheme://a/b/", "./././x/../././.", true,
620 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a/b/" },
622 { "scheme:a", "", true,
623 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a" },
624 { "scheme:a", ".", true,
625 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:" },
626 { "scheme:a", "./", true,
627 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:" },
628 { "scheme:a", "./.", true,
629 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:" },
630 { "scheme:a", "././", true,
631 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:" },
632 { "scheme:a", "././.", true,
633 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:" },
634 { "scheme:a", "x/..", true,
635 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
636 { "scheme:a", "x/../", true,
637 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
638 { "scheme:a", "x/../.", true,
639 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
640 { "scheme:a", "x/.././", true,
641 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
642 { "scheme:a", "x/.././.", true,
643 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
644 { "scheme:a", "x/../././", true,
645 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
646 { "scheme:a", "x/../././.", true,
647 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
648 { "scheme:a", "./x/..", true,
649 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
650 { "scheme:a", "././x/..", true,
651 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
652 { "scheme:a", "./././x/..", true,
653 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
654 { "scheme:a", "./x/../.", true,
655 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
656 { "scheme:a", "./x/.././", true,
657 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
658 { "scheme:a", "././x/.././.", true,
659 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
660 { "scheme:a", "././x/../././", true,
661 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
662 { "scheme:a", "./././x/../././.", true,
663 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
665 { "scheme:a/", "", true,
666 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
667 { "scheme:a/", ".", true,
668 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
669 { "scheme:a/", "./", true,
670 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
671 { "scheme:a/", "./.", true,
672 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
673 { "scheme:a/", "././", true,
674 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
675 { "scheme:a/", "././.", true,
676 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
677 { "scheme:a/", "x/..", true,
678 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
679 { "scheme:a/", "x/../", true,
680 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
681 { "scheme:a/", "x/../.", true,
682 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
683 { "scheme:a/", "x/.././", true,
684 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
685 { "scheme:a/", "x/.././.", true,
686 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
687 { "scheme:a/", "x/../././", true,
688 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
689 { "scheme:a/", "x/../././.", true,
690 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
691 { "scheme:a/", "./x/..", true,
692 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
693 { "scheme:a/", "././x/..", true,
694 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
695 { "scheme:a/", "./././x/..", true,
696 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
697 { "scheme:a/", "./x/../.", true,
698 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
699 { "scheme:a/", "./x/.././", true,
700 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
701 { "scheme:a/", "././x/.././.", true,
702 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
703 { "scheme:a/", "././x/../././", true,
704 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
705 { "scheme:a/", "./././x/../././.", true,
706 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
708 { "scheme:a/b", "", true,
709 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b" },
710 { "scheme:a/b", ".", true,
711 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
712 { "scheme:a/b", "./", true,
713 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
714 { "scheme:a/b", "./.", true,
715 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
716 { "scheme:a/b", "././", true,
717 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
718 { "scheme:a/b", "././.", true,
719 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
720 { "scheme:a/b", "x/..", true,
721 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
722 { "scheme:a/b", "x/../", true,
723 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
724 { "scheme:a/b", "x/../.", true,
725 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
726 { "scheme:a/b", "x/.././", true,
727 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
728 { "scheme:a/b", "x/.././.", true,
729 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
730 { "scheme:a/b", "x/../././", true,
731 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
732 { "scheme:a/b", "x/../././.", true,
733 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
734 { "scheme:a/b", "./x/..", true,
735 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
736 { "scheme:a/b", "././x/..", true,
737 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
738 { "scheme:a/b", "./././x/..", true,
739 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
740 { "scheme:a/b", "./x/../.", true,
741 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
742 { "scheme:a/b", "./x/.././", true,
743 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
744 { "scheme:a/b", "././x/.././.", true,
745 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
746 { "scheme:a/b", "././x/../././", true,
747 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
748 { "scheme:a/b", "./././x/../././.", true,
749 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/" },
751 { "scheme:a/b/", "", true,
752 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b/" },
753 { "scheme:a/b/", ".", true,
754 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b/" },
755 { "scheme:a/b/", "./", true,
756 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b/" },
757 { "scheme:a/b/", "./.", true,
758 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b/" },
759 { "scheme:a/b/", "././", true,
760 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b/" },
761 { "scheme:a/b/", "././.", true,
762 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b/" },
763 { "scheme:a/b/", "x/..", true,
764 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b/" },
765 { "scheme:a/b/", "x/../", true,
766 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b/" },
767 { "scheme:a/b/", "x/../.", true,
768 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b/" },
769 { "scheme:a/b/", "x/.././", true,
770 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b/" },
771 { "scheme:a/b/", "x/.././.", true,
772 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b/" },
773 { "scheme:a/b/", "x/../././", true,
774 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b/" },
775 { "scheme:a/b/", "x/../././.", true,
776 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b/" },
777 { "scheme:a/b/", "./x/..", true,
778 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b/" },
779 { "scheme:a/b/", "././x/..", true,
780 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b/" },
781 { "scheme:a/b/", "./././x/..", true,
782 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b/" },
783 { "scheme:a/b/", "./x/../.", true,
784 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b/" },
785 { "scheme:a/b/", "./x/.././", true,
786 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b/" },
787 { "scheme:a/b/", "././x/.././.", true,
788 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b/" },
789 { "scheme:a/b/", "././x/../././", true,
790 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b/" },
791 { "scheme:a/b/", "./././x/../././.", true,
792 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:a/b/" },
794 { "scheme:/a", "", true,
795 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a" },
796 { "scheme:/a", ".", true,
797 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
798 { "scheme:/a", "./", true,
799 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
800 { "scheme:/a", "./.", true,
801 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
802 { "scheme:/a", "././", true,
803 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
804 { "scheme:/a", "././.", true,
805 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
806 { "scheme:/a", "x/..", true,
807 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
808 { "scheme:/a", "x/../", true,
809 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
810 { "scheme:/a", "x/../.", true,
811 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
812 { "scheme:/a", "x/.././", true,
813 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
814 { "scheme:/a", "x/.././.", true,
815 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
816 { "scheme:/a", "x/../././", true,
817 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
818 { "scheme:/a", "x/../././.", true,
819 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
820 { "scheme:/a", "./x/..", true,
821 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
822 { "scheme:/a", "././x/..", true,
823 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
824 { "scheme:/a", "./././x/..", true,
825 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
826 { "scheme:/a", "./x/../.", true,
827 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
828 { "scheme:/a", "./x/.././", true,
829 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
830 { "scheme:/a", "././x/.././.", true,
831 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
832 { "scheme:/a", "././x/../././", true,
833 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
834 { "scheme:/a", "./././x/../././.", true,
835 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/" },
837 { "scheme:/a/", "", true,
838 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
839 { "scheme:/a/", ".", true,
840 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
841 { "scheme:/a/", "./", true,
842 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
843 { "scheme:/a/", "./.", true,
844 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
845 { "scheme:/a/", "././", true,
846 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
847 { "scheme:/a/", "././.", true,
848 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
849 { "scheme:/a/", "x/..", true,
850 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
851 { "scheme:/a/", "x/../", true,
852 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
853 { "scheme:/a/", "x/../.", true,
854 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
855 { "scheme:/a/", "x/.././", true,
856 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
857 { "scheme:/a/", "x/.././.", true,
858 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
859 { "scheme:/a/", "x/../././", true,
860 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
861 { "scheme:/a/", "x/../././.", true,
862 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
863 { "scheme:/a/", "./x/..", true,
864 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
865 { "scheme:/a/", "././x/..", true,
866 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
867 { "scheme:/a/", "./././x/..", true,
868 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
869 { "scheme:/a/", "./x/../.", true,
870 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
871 { "scheme:/a/", "./x/.././", true,
872 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
873 { "scheme:/a/", "././x/.././.", true,
874 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
875 { "scheme:/a/", "././x/../././", true,
876 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
877 { "scheme:/a/", "./././x/../././.", true,
878 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
880 { "scheme:/a/b", "", true,
881 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b" },
882 { "scheme:/a/b", ".", true,
883 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
884 { "scheme:/a/b", "./", true,
885 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
886 { "scheme:/a/b", "./.", true,
887 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
888 { "scheme:/a/b", "././", true,
889 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
890 { "scheme:/a/b", "././.", true,
891 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
892 { "scheme:/a/b", "x/..", true,
893 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
894 { "scheme:/a/b", "x/../", true,
895 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
896 { "scheme:/a/b", "x/../.", true,
897 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
898 { "scheme:/a/b", "x/.././", true,
899 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
900 { "scheme:/a/b", "x/.././.", true,
901 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
902 { "scheme:/a/b", "x/../././", true,
903 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
904 { "scheme:/a/b", "x/../././.", true,
905 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
906 { "scheme:/a/b", "./x/..", true,
907 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
908 { "scheme:/a/b", "././x/..", true,
909 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
910 { "scheme:/a/b", "./././x/..", true,
911 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
912 { "scheme:/a/b", "./x/../.", true,
913 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
914 { "scheme:/a/b", "./x/.././", true,
915 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
916 { "scheme:/a/b", "././x/.././.", true,
917 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
918 { "scheme:/a/b", "././x/../././", true,
919 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
920 { "scheme:/a/b", "./././x/../././.", true,
921 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/" },
923 { "scheme:/a/b/", "", true,
924 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b/" },
925 { "scheme:/a/b/", ".", true,
926 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b/" },
927 { "scheme:/a/b/", "./", true,
928 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b/" },
929 { "scheme:/a/b/", "./.", true,
930 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b/" },
931 { "scheme:/a/b/", "././", true,
932 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b/" },
933 { "scheme:/a/b/", "././.", true,
934 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b/" },
935 { "scheme:/a/b/", "x/..", true,
936 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b/" },
937 { "scheme:/a/b/", "x/../", true,
938 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b/" },
939 { "scheme:/a/b/", "x/../.", true,
940 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b/" },
941 { "scheme:/a/b/", "x/.././", true,
942 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b/" },
943 { "scheme:/a/b/", "x/.././.", true,
944 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b/" },
945 { "scheme:/a/b/", "x/../././", true,
946 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b/" },
947 { "scheme:/a/b/", "x/../././.", true,
948 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b/" },
949 { "scheme:/a/b/", "./x/..", true,
950 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b/" },
951 { "scheme:/a/b/", "././x/..", true,
952 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b/" },
953 { "scheme:/a/b/", "./././x/..", true,
954 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b/" },
955 { "scheme:/a/b/", "./x/../.", true,
956 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b/" },
957 { "scheme:/a/b/", "./x/.././", true,
958 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b/" },
959 { "scheme:/a/b/", "././x/.././.", true,
960 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b/" },
961 { "scheme:/a/b/", "././x/../././", true,
962 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b/" },
963 { "scheme:/a/b/", "./././x/../././.", true,
964 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme:/a/b/" },
966 { "scheme://a#s", "", true,
967 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a" },
968 { "scheme://a", "?q", true,
969 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a?q" },
970 { "scheme://a#s", "?q", true,
971 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a?q" },
972 { "scheme://a", "#s", true,
973 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a#s" },
974 { "scheme://a#s1", "#s2", true,
975 css::uri::RelativeUriExcessParentSegments_REMOVE, "scheme://a#s2" },
977 { "schema://a", "schema://b/c/../d", true, css::uri::RelativeUriExcessParentSegments_REMOVE,
978 "schema://b/d" },
980 // Per RFC 3986 Section 5.2.1 "Pre-parse the Base URI", "Normalization of the base URI
981 // [...; esp. dot-segment removal per Section 6.2.2.3 "Path Segment Normalization"] is
982 // optional" (and not done by our implementation), so if the relative URI has no scheme and
983 // no authority and an empty path, the Base URI's path is used unmodified per Section 5.2.2
984 // "Transform References" and thus still contains dot-segments:
985 { "scheme:/a/../b/c", "", true, css::uri::RelativeUriExcessParentSegments_REMOVE,
986 "scheme:/a/../b/c" },
987 { "scheme:/a/../b/c", "d", true, css::uri::RelativeUriExcessParentSegments_REMOVE,
988 "scheme:/b/d" } };
989 for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
990 css::uno::Reference< css::uri::XUriReference > baseUriRef(
991 m_uriFactory->parse(
992 OUString::createFromAscii(data[i].baseUriReference)));
993 TEST_ASSERT_EQUAL("testMakeAbsolute", i, data[i].baseUriReference, true, baseUriRef.is());
994 css::uno::Reference< css::uri::XUriReference > uriRef(
995 m_uriFactory->parse(
996 OUString::createFromAscii(data[i].uriReference)));
997 TEST_ASSERT_EQUAL("testMakeAbsolute", i, data[i].uriReference, true, uriRef.is());
998 css::uno::Reference< css::uri::XUriReference > absolute(
999 m_uriFactory->makeAbsolute(
1000 baseUriRef, uriRef, data[i].processSpecialBaseSegments,
1001 data[i].excessParentSegments));
1002 TEST_ASSERT_EQUAL(
1003 "testMakeAbsolute", i, data[i].uriReference,
1004 data[i].absolute != nullptr, absolute.is());
1005 if (absolute.is()) {
1006 TEST_ASSERT_EQUAL(
1007 "testMakeAbsolute", i, data[i].uriReference,
1008 OUString::createFromAscii(data[i].absolute),
1009 absolute->getUriReference());
1011 // For those test cases that conform to RFC 3986, check that the behavior matches
1012 // rtl::Uri::convertRelToAbs:
1013 if (data[i].processSpecialBaseSegments
1014 && data[i].excessParentSegments == css::uri::RelativeUriExcessParentSegments_REMOVE)
1016 try {
1017 auto const absolute2 = rtl::Uri::convertRelToAbs(
1018 OUString::createFromAscii(data[i].baseUriReference),
1019 OUString::createFromAscii(data[i].uriReference));
1020 TEST_ASSERT_EQUAL(
1021 "testMakeAbsolute", i, data[i].uriReference, true, data[i].absolute != nullptr);
1022 TEST_ASSERT_EQUAL(
1023 "testMakeAbsolute", i, data[i].uriReference,
1024 OUString::createFromAscii(data[i].absolute), absolute2);
1025 } catch (rtl::MalformedUriException &) {
1026 TEST_ASSERT_EQUAL(
1027 "testMakeAbsolute", i, data[i].uriReference, true, data[i].absolute == nullptr);
1033 void Test::testMakeRelative() {
1034 struct Data {
1035 char const * baseUriReference;
1036 char const * uriReference;
1037 bool preferAuthorityOverRelativePath;
1038 bool preferAbsoluteOverRelativePath;
1039 bool encodeRetainedSpecialSegments;
1040 char const * relative;
1041 char const * absolute;
1043 Data data[] = {
1044 { "scheme1://a/b/c", "scheme2://a/b/c?q#s", true, true, false,
1045 "scheme2://a/b/c?q#s", nullptr },
1046 { "scheme://a/b/c", "scheme:a/b/c?q#s", true, true, false,
1047 "scheme:a/b/c?q#s", nullptr },
1048 { "scheme://a/b/c", "", true, true, false, "", "scheme://a/b/c" },
1049 { "scheme://a/b/c", "//d/e/f", true, true, false, "//d/e/f",
1050 "scheme://d/e/f" },
1051 { "scheme://a/b/c", "./e?q#s", true, true, false, "./e?q#s",
1052 "scheme://a/b/e?q#s" },
1053 { "scheme://a/b", "scheme://a?q", true, true, false, "/?q",
1054 "scheme://a/?q" },
1055 { "scheme://a/b", "scheme://a?q", true, false, false, "/?q",
1056 "scheme://a/?q" },
1057 { "scheme://a", "scheme://a?q", true, true, false, "?q", nullptr },
1058 { "scheme://a/", "scheme://a?q", true, true, false, "?q",
1059 "scheme://a/?q" },
1060 { "scheme://a", "scheme://a/?q", true, true, false, "/?q",
1061 nullptr },
1062 { "scheme://a/", "scheme://a/?q", true, true, false, "?q",
1063 nullptr },
1064 { "scheme://a?q", "scheme://a?q", true, true, false, "", nullptr },
1065 { "scheme://a/?q", "scheme://a?q", true, true, false, "",
1066 "scheme://a/?q" },
1067 { "scheme://a?q", "scheme://a/?q", true, true, false, "/?q",
1068 nullptr },
1069 { "scheme://a/?q", "scheme://a/?q", true, true, false, "", nullptr },
1070 { "scheme://a/b/c/d", "scheme://a//", true, true, false, "//a//", nullptr },
1071 { "scheme://a/b/c/d", "scheme://a//", false, true, false, "../..//",
1072 nullptr },
1073 { "scheme://a/b/c/d", "scheme://a//", true, false, false, "../..//",
1074 nullptr },
1075 { "scheme://a/b/c/d", "scheme://a//", false, false, false, "../..//",
1076 nullptr },
1077 { "scheme://a/b/c/d", "scheme://a/e", true, true, false, "/e", nullptr },
1078 { "scheme://a/b/c/d", "scheme://a/e", true, false, false, "../../e",
1079 nullptr },
1080 { "scheme://a/b/c/d/e", "scheme://a/b/f", true, true, false, "../../f",
1081 nullptr },
1082 { "scheme://a/b/c/d/e", "scheme://a/b", true, true, false, "/b", nullptr },
1083 { "scheme://a/b/c/d/e", "scheme://a/b", true, false, false,
1084 "../../../b", nullptr },
1085 { "scheme://a/b/c/d/e", "scheme://a/b/", true, true, false, "../..",
1086 nullptr },
1087 { "scheme://a/b/c/d/e", "scheme://a/b/c", true, true, false, "../../c",
1088 nullptr },
1089 { "scheme://a/b/c/d/e", "scheme://a/b/c/", true, true, false, "..", nullptr },
1090 { "scheme://a/b/", "scheme://a/b/c/d", true, true, false, "c/d", nullptr },
1091 { "scheme://a/b/", "scheme://a/b/c/d/", true, true, false, "c/d/", nullptr },
1092 { "scheme://a/b/c", "scheme://a/b//", true, true, false, ".//", nullptr },
1093 { "scheme://a/b/c", "scheme://a/b//d", true, true, false, ".//d", nullptr },
1094 { "scheme://a/b/c", "scheme://a/b//d//", true, true, false, ".//d//",
1095 nullptr },
1096 { "scheme://a/b/c", "scheme://a/b/d+:", true, true, false, "./d+:", nullptr },
1097 { "scheme://a/b/c", "scheme://a/b/+d:", true, true, false, "+d:", nullptr },
1098 { "scheme://a/b/c", "scheme://a/b/d#e:f", true, true, false, "d#e:f",
1099 nullptr },
1100 { "scheme://a/b/c/", "scheme://a/b/../d/.e/.", true, true, false,
1101 "../../d/.e/.",
1102 "scheme://a/d/.e/" },
1103 { "scheme://a/b/c/", "scheme://a/b/../d/.e/.", true, true, true,
1104 "../%2E%2E/d/.e/%2E", "scheme://a/b/%2E%2E/d/.e/%2E" },
1105 { "scheme://auth/a/b", "scheme://auth//c/d", true, true, false,
1106 "//auth//c/d", nullptr },
1107 { "scheme://auth/a/b", "scheme://auth//c/d", false, true, false,
1108 "..//c/d", nullptr },
1109 { "scheme://auth/a/b", "scheme://auth/c/d", true, true, false, "/c/d",
1110 nullptr },
1111 { "scheme://auth/a/b", "scheme://auth/c/d", true, false, false,
1112 "../c/d", nullptr },
1113 { "scheme:a/b/c", "scheme://d/e/f", true, true, false, "//d/e/f", nullptr },
1114 { "scheme:/a/b/c", "scheme://d/e/f", true, true, false, "//d/e/f", nullptr },
1115 { "scheme:a/b/c", "scheme:/d/e/f", true, true, false, "/d/e/f", nullptr },
1116 { "scheme:/a/b/c", "scheme:/d/e/f", true, true, false, "/d/e/f", nullptr },
1117 { "scheme:a/b/c", "scheme:d/e/f", true, true, false, "scheme:d/e/f", nullptr },
1118 { "scheme:/a/b/c", "scheme:d/e/f", true, true, false, "scheme:d/e/f", nullptr } };
1119 for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
1120 css::uno::Reference< css::uri::XUriReference > baseUriRef(
1121 m_uriFactory->parse(
1122 OUString::createFromAscii(data[i].baseUriReference)));
1123 TEST_ASSERT_EQUAL("testMakeRelative", i, data[i].baseUriReference, true, baseUriRef.is());
1124 css::uno::Reference< css::uri::XUriReference > uriRef(
1125 m_uriFactory->parse(
1126 OUString::createFromAscii(data[i].uriReference)));
1127 TEST_ASSERT_EQUAL("testMakeRelative", i, data[i].uriReference, true, uriRef.is());
1128 css::uno::Reference< css::uri::XUriReference > relative(
1129 m_uriFactory->makeRelative(
1130 baseUriRef, uriRef, data[i].preferAuthorityOverRelativePath,
1131 data[i].preferAbsoluteOverRelativePath,
1132 data[i].encodeRetainedSpecialSegments));
1133 TEST_ASSERT_EQUAL(
1134 "testMakeRelative", i, data[i].uriReference,
1135 data[i].relative != nullptr, relative.is());
1136 if (relative.is()) {
1137 TEST_ASSERT_EQUAL(
1138 "testMakeRelative", i, data[i].uriReference,
1139 OUString::createFromAscii(data[i].relative),
1140 relative->getUriReference());
1141 css::uno::Reference< css::uri::XUriReference > absolute(
1142 m_uriFactory->makeAbsolute(
1143 baseUriRef, relative, true,
1144 css::uri::RelativeUriExcessParentSegments_ERROR));
1145 TEST_ASSERT_EQUAL("testMakeRelative", i, data[i].uriReference, true, absolute.is());
1146 TEST_ASSERT_EQUAL(
1147 "testMakeRelative", i, data[i].uriReference,
1148 OUString::createFromAscii(
1149 data[i].absolute == nullptr
1150 ? data[i].uriReference : data[i].absolute),
1151 absolute->getUriReference());
1156 void Test::testVndSunStarExpand() {
1157 struct Data {
1158 char const * uriReference;
1159 char const * expanded;
1161 Data data[] = {
1162 { "vnd.sun.star.expand:", "" }, // liberally accepted
1163 { "vnd.sun.star.expand:/", "/" }, // liberally accepted
1164 { "vnd.sun.star.expand:%80", nullptr },
1165 { "vnd.sun.star.expand:%5C$%5C%24%5C%5C", "$$\\" } };
1166 css::uno::Reference< css::util::XMacroExpander > expander(
1167 m_context->getValueByName(
1168 "/singletons/com.sun.star.util.theMacroExpander"),
1169 css::uno::UNO_QUERY_THROW);
1170 for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
1171 css::uno::Reference< css::uri::XUriReference > uriRef(
1172 m_uriFactory->parse(
1173 OUString::createFromAscii(data[i].uriReference)));
1174 TEST_ASSERT_EQUAL(
1175 "testVndSunStarExpand", i, data[i].uriReference,
1176 data[i].expanded != nullptr, uriRef.is());
1177 if (uriRef.is()) {
1178 css::uno::Reference< css::uri::XVndSunStarExpandUrlReference >
1179 expandUrl(uriRef, css::uno::UNO_QUERY_THROW);
1180 TEST_ASSERT_EQUAL(
1181 "testVndSunStarExpand", i, data[i].uriReference,
1182 OUString::createFromAscii(data[i].expanded),
1183 expandUrl->expand(expander));
1188 void Test::testVndSunStarScript() {
1189 struct Parameter {
1190 char const * key;
1191 char const * value;
1193 std::size_t const parameterCount = 3;
1194 struct Data {
1195 char const * uriReference;
1196 char const * name;
1197 const bool normalized;
1198 Parameter parameters[parameterCount];
1200 Data data[] = {
1201 { "vnd.sun.star.script:", nullptr, false, {} },
1202 { "vnd.sun.star.script:/", nullptr, false, {} },
1203 { "vnd.sun.star.script:/abc/def?ghi=jkl&mno=pqr", nullptr, false, {} },
1204 { "vnd.sun.star.script:abc%3fdef/ghi", "abc?def/ghi", false, {} },
1205 { "vnd.sun.star.script:name?a", nullptr, false, {} },
1206 { "vnd.sun.star.script:name?a=", "name", true, { { "a", "" }, { "A", nullptr } } },
1207 { "vnd.sun.star.script:name?a=&", nullptr, true, {} },
1208 { "vnd.sun.star.script:name?key1=&%26=%3D&key1=hello", "name", true,
1209 { { "key1", "" }, { "key2", nullptr }, { "&", "=" } } } };
1210 for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
1211 css::uno::Reference< css::uri::XUriReference > uriRef(
1212 m_uriFactory->parse(
1213 OUString::createFromAscii(data[i].uriReference)));
1214 TEST_ASSERT_EQUAL(
1215 "testVndSunStarScript", i, data[i].uriReference, data[i].name != nullptr,
1216 uriRef.is());
1217 if (uriRef.is()) {
1218 css::uno::Reference< css::uri::XVndSunStarScriptUrlReference >
1219 scriptUrl(uriRef, css::uno::UNO_QUERY_THROW);
1220 TEST_ASSERT_EQUAL(
1221 "testVndSunStarScript", i, data[i].uriReference,
1222 OUString::createFromAscii(data[i].uriReference),
1223 scriptUrl->getUriReference());
1224 TEST_ASSERT_EQUAL(
1225 "testVndSunStarScript", i, data[i].uriReference,
1226 OUString::createFromAscii(data[i].name),
1227 scriptUrl->getName());
1228 OUString originalReference(uriRef->getUriReference());
1229 for (std::size_t j = 0; j < parameterCount; ++j) {
1230 if (data[i].parameters[j].key != nullptr) {
1231 TEST_ASSERT_EQUAL(
1232 "testVndSunStarScript",
1233 static_cast< double >(i)
1234 + static_cast< double >(j) / 10.0,
1235 data[i].uriReference,
1236 data[i].parameters[j].value != nullptr,
1237 bool(
1238 scriptUrl->hasParameter(
1239 OUString::createFromAscii(
1240 data[i].parameters[j].key))));
1241 TEST_ASSERT_EQUAL(
1242 "testVndSunStarScript",
1243 static_cast< double >(i)
1244 + static_cast< double >(j) / 10.0,
1245 data[i].uriReference,
1246 OUString::createFromAscii(
1247 data[i].parameters[j].value),
1248 scriptUrl->getParameter(
1249 OUString::createFromAscii(
1250 data[i].parameters[j].key)));
1252 // setting the parameter to its original value should not change
1253 // the overall uri reference (provided it was normalized before)
1254 if ( data[i].normalized ) {
1255 if ( scriptUrl->hasParameter(OUString::createFromAscii(
1256 data[i].parameters[j].key)) ) {
1257 scriptUrl->setParameter(
1258 OUString::createFromAscii(
1259 data[i].parameters[j].key),
1260 scriptUrl->getParameter(
1261 OUString::createFromAscii(
1262 data[i].parameters[j].key)));
1263 TEST_ASSERT_EQUAL(
1264 "testVndSunStarScript",
1265 static_cast< double >(i)
1266 + static_cast< double >(j) / 10.0,
1267 OUString("setParameter"),
1268 originalReference,
1269 uriRef->getUriReference());
1274 if ( data[i].normalized ) {
1275 scriptUrl->setName(scriptUrl->getName());
1276 TEST_ASSERT_EQUAL(
1277 "testVndSunStarScript",
1279 OUString("setName"),
1280 originalReference,
1281 uriRef->getUriReference());
1286 css::uno::Reference< css::uri::XUriReference > uriRef(
1287 m_uriFactory->parse(
1288 "vnd.sun.star.script:Hello?location=Library.Module"),
1289 css::uno::UNO_SET_THROW);
1290 css::uno::Reference< css::uri::XVndSunStarScriptUrlReference >
1291 scriptUrl(uriRef, css::uno::UNO_QUERY_THROW);
1293 scriptUrl->setParameter(
1294 "location",
1295 "foo");
1296 TEST_ASSERT_EQUAL(
1297 "testVndSunStarScript", sal_Int32(10), sal_Int32(1),
1298 OUString("vnd.sun.star.script:Hello?location=foo"),
1299 uriRef->getUriReference());
1301 scriptUrl->setParameter(
1302 "language",
1303 "StarBasic");
1304 TEST_ASSERT_EQUAL(
1305 "testVndSunStarScript", sal_Int32(10), sal_Int32(2),
1306 OUString("vnd.sun.star.script:Hello?location=foo&language=StarBasic"),
1307 uriRef->getUriReference());
1310 bool caughtExpected = false;
1311 try {
1312 scriptUrl->setName(OUString());
1314 catch( const css::lang::IllegalArgumentException& ) {
1315 caughtExpected = true;
1317 TEST_ASSERT_EQUAL(
1318 "testVndSunStarScript",
1319 OUString("illegal arguments"),
1320 OUString("name"),
1321 true,
1322 caughtExpected);
1324 caughtExpected = false;
1325 try {
1326 scriptUrl->setParameter(
1327 OUString(),
1328 "non-empty");
1330 catch( const css::lang::IllegalArgumentException& ) {
1331 caughtExpected = true;
1333 TEST_ASSERT_EQUAL(
1334 "testVndSunStarScript",
1335 OUString("illegal arguments"),
1336 OUString("parameter"),
1337 true,
1338 caughtExpected);
1341 void Test::testTranslator() {
1342 struct Data {
1343 char const * externalUriReference;
1344 char const * internalUriReference;
1345 bool toInternal;
1347 Data data[] = {
1348 { "", "", true },
1349 { "#fragment", "#fragment", true },
1350 { "segment/segment?query#fragment", "segment/segment?query#fragment",
1351 true },
1352 { "/segment/segment?query#fragment", "/segment/segment?query#fragment",
1353 true },
1354 { "//authority/segment?query#fragment",
1355 "//authority/segment?query#fragment", true },
1356 { "foo:bar#fragment", "foo:bar#fragment", true },
1357 { "file:///abc/def", "file:///abc/def", true },
1358 { "file:///abc/%FEef", "file:///abc/%feef", false },
1359 { "file:///abc/%80%80ef", "file:///abc/%80%80ef", false },
1360 { "file:///abc/%ED%A0%80%ED%B0%80ef",
1361 "file:///abc/%ED%A0%80%ED%B0%80ef", false },
1362 { "file:///abc/%25.ef", "file:///abc/%.ef", false },
1363 { "file:///abc/%25ef", "file:///abc/%25ef", true } };
1364 css::uno::Reference< css::uri::XExternalUriReferenceTranslator >
1365 translator(css::uri::ExternalUriReferenceTranslator::create(m_context));
1366 for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
1367 if (data[i].toInternal) {
1368 TEST_ASSERT_EQUAL(
1369 "testTranslator, translateToInternal", i,
1370 data[i].externalUriReference,
1371 OUString::createFromAscii(data[i].internalUriReference),
1372 translator->translateToInternal(
1373 OUString::createFromAscii(
1374 data[i].externalUriReference)));
1376 TEST_ASSERT_EQUAL(
1377 "testTranslator, translateToExternal", i,
1378 data[i].internalUriReference,
1379 OUString::createFromAscii(data[i].externalUriReference),
1380 translator->translateToExternal(
1381 OUString::createFromAscii(data[i].internalUriReference)));
1385 void Test::testPkgUrlFactory() {
1386 struct Data {
1387 char const * authority;
1388 char const * result;
1390 Data data[] = {
1391 { "a/b/c", nullptr },
1392 { "file:///#foo", nullptr },
1393 { "file:///a%25b%2fc/d~e&f@g?h",
1394 "vnd.sun.star.pkg://file:%2F%2F%2Fa%2525b%252fc%2Fd~e&f@g%3Fh" } };
1395 css::uno::Reference< css::uri::XVndSunStarPkgUrlReferenceFactory > factory(
1396 css::uri::VndSunStarPkgUrlReferenceFactory::create(m_context));
1397 for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
1398 css::uno::Reference< css::uri::XUriReference > url(
1399 factory->createVndSunStarPkgUrlReference(
1400 m_uriFactory->parse(
1401 OUString::createFromAscii(data[i].authority))));
1402 TEST_ASSERT_EQUAL(
1403 "testVndSunStarPkgFactory", i, data[i].authority,
1404 data[i].result != nullptr, url.is());
1405 if (data[i].result != nullptr) {
1406 TEST_ASSERT_EQUAL(
1407 "testVndSunStarPkgFactory", i, data[i].authority,
1408 OUString::createFromAscii(data[i].result),
1409 url->getUriReference());
1414 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
1418 CPPUNIT_PLUGIN_IMPLEMENT();
1420 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */