summaryrefslogtreecommitdiff
path: root/stoc
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-08-20 09:38:10 +0200
committerStephan Bergmann <sbergman@redhat.com>2019-08-23 14:47:01 +0200
commit5bbf9ca7ccb60c9d90f2cabbe4be4962329fda61 (patch)
tree58eab725c95f9e5c79391342f0dcf0a30fd25cdd /stoc
parent9a251699d728fa6207b71406cd91aafb7803f453 (diff)
[API CHANGE] Adapt css.uri UNOIDL entities to RFC 3986
...which obsoleted RFC 2396. Notable changes are that the distinction between hierarchical and opaque URIs has been dropped, and that the relative URI resolution specification has been made more rigid. As a consequence, various features of css.uri entities have changed: * XUriReference.isHierarchical is obsolete and deprecated. * The behavior of XUriReference.hasAuthority, XUriReference.getAuthority, XUriReference.getPath, XUriReference.hasRelativePath, XUriReference.getPathSegmentCount, XUriReference.getPathSegment, XUriReference.hasQuery, and XUriReference.getQuery has been made consistent for all URIs, no matter whether they were considered hierarchical or opaque in the past. * The behavior of XUriReferenceFactory.makeAbsolute and XUriReferenceFactory.makeRelative has been changed to match the RFC 3986 reference resolution specification. The XUriReferenceFactory.makeAbsolulte parameter processSpecialBaseSegments has been renamed to processAdditionalSpecialSegments, as per the updated specification it now controls treatment of special segments in the given uriReference, in addition to special segments in the given baseUriReference. (Renaming UNOIDL interface method parameters is technically an incompatible change, but the benefits of improved clarity presumably outweigh any potential drawbacks in this case.) The implementation in stoc has been adapted, and various call sites have been adapted to the deprecated XUriReference.isHierarchical semantics. Change-Id: Ic6e00fdbce5abef70d75ec2f753d22fefe361457 Reviewed-on: https://gerrit.libreoffice.org/77861 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'stoc')
-rw-r--r--stoc/source/uriproc/UriReference.cxx14
-rw-r--r--stoc/source/uriproc/UriReference.hxx3
-rw-r--r--stoc/source/uriproc/UriReferenceFactory.cxx375
-rw-r--r--stoc/source/uriproc/UriSchemeParser_vndDOTsunDOTstarDOTexpand.cxx2
-rw-r--r--stoc/source/uriproc/UriSchemeParser_vndDOTsunDOTstarDOTscript.cxx2
-rw-r--r--stoc/test/uriproc/test_uriproc.cxx478
6 files changed, 687 insertions, 187 deletions
diff --git a/stoc/source/uriproc/UriReference.cxx b/stoc/source/uriproc/UriReference.cxx
index 28202b7aeac3..468d6653d2c5 100644
--- a/stoc/source/uriproc/UriReference.cxx
+++ b/stoc/source/uriproc/UriReference.cxx
@@ -29,22 +29,18 @@
using stoc::uriproc::UriReference;
UriReference::UriReference(
- OUString const & scheme, bool bIsHierarchical, bool bHasAuthority,
+ OUString const & scheme, bool bHasAuthority,
OUString const & authority, OUString const & path,
bool bHasQuery, OUString const & query):
m_scheme(scheme),
m_authority(authority),
m_path(path),
m_query(query),
- m_isHierarchical(bIsHierarchical),
m_hasAuthority(bHasAuthority),
m_hasQuery(bHasQuery),
m_hasFragment(false)
{
- OSL_ASSERT(!scheme.isEmpty() || bIsHierarchical);
- OSL_ASSERT(!bHasAuthority || bIsHierarchical);
OSL_ASSERT(authority.isEmpty() || bHasAuthority);
- OSL_ASSERT(!bHasQuery || bIsHierarchical);
OSL_ASSERT(query.isEmpty() || bHasQuery);
}
@@ -81,7 +77,7 @@ OUString UriReference::getSchemeSpecificPart()
bool UriReference::isHierarchical() {
osl::MutexGuard g(m_mutex);
- return m_isHierarchical;
+ return m_scheme.isEmpty() || m_hasAuthority || m_path.startsWith("/");
}
bool UriReference::hasAuthority() {
@@ -101,14 +97,14 @@ OUString UriReference::getPath() {
bool UriReference::hasRelativePath() {
osl::MutexGuard g(m_mutex);
- return m_isHierarchical && !m_hasAuthority
+ return !m_hasAuthority
&& (m_path.isEmpty() || m_path[0] != '/');
}
sal_Int32 UriReference::getPathSegmentCount()
{
osl::MutexGuard g(m_mutex);
- if (!m_isHierarchical || m_path.isEmpty()) {
+ if (m_path.isEmpty()) {
return 0;
} else {
sal_Int32 n = m_path[0] == '/' ? 0 : 1;
@@ -126,7 +122,7 @@ sal_Int32 UriReference::getPathSegmentCount()
OUString UriReference::getPathSegment(sal_Int32 index)
{
osl::MutexGuard g(m_mutex);
- if (m_isHierarchical && !m_path.isEmpty() && index >= 0) {
+ if (!m_path.isEmpty() && index >= 0) {
for (sal_Int32 i = m_path[0] == '/' ? 1 : 0;; ++i) {
if (index-- == 0) {
sal_Int32 j = m_path.indexOf('/', i);
diff --git a/stoc/source/uriproc/UriReference.hxx b/stoc/source/uriproc/UriReference.hxx
index fe2f9bb38d19..2f56bfc6f7ca 100644
--- a/stoc/source/uriproc/UriReference.hxx
+++ b/stoc/source/uriproc/UriReference.hxx
@@ -30,7 +30,7 @@ namespace stoc { namespace uriproc {
class UriReference {
public:
UriReference(
- OUString const & scheme, bool isHierarchical, bool hasAuthority,
+ OUString const & scheme, bool hasAuthority,
OUString const & authority, OUString const & path,
bool hasQuery, OUString const & query);
@@ -93,7 +93,6 @@ public:
OUString m_path;
OUString const m_query;
OUString m_fragment;
- bool const m_isHierarchical;
bool const m_hasAuthority;
bool const m_hasQuery;
bool m_hasFragment;
diff --git a/stoc/source/uriproc/UriReferenceFactory.cxx b/stoc/source/uriproc/UriReferenceFactory.cxx
index 779bb36b627b..3a5f30b850de 100644
--- a/stoc/source/uriproc/UriReferenceFactory.cxx
+++ b/stoc/source/uriproc/UriReferenceFactory.cxx
@@ -21,7 +21,9 @@
#include <algorithm>
#include <cassert>
-#include <cstdlib>
+#include <cstddef>
+#include <string_view>
+#include <utility>
#include <vector>
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
@@ -96,11 +98,11 @@ class UriReference:
{
public:
UriReference(
- OUString const & scheme, bool bIsHierarchical, bool bHasAuthority,
+ OUString const & scheme, bool bHasAuthority,
OUString const & authority, OUString const & path,
bool bHasQuery, OUString const & query):
m_base(
- scheme, bIsHierarchical, bHasAuthority, authority, path, bHasQuery,
+ scheme, bHasAuthority, authority, path, bHasQuery,
query)
{}
@@ -167,75 +169,113 @@ private:
css::uno::Reference< css::uri::XUriReference > parseGeneric(
OUString const & scheme, OUString const & schemeSpecificPart)
{
- bool isAbsolute = !scheme.isEmpty();
- bool isHierarchical = !isAbsolute || schemeSpecificPart.startsWith("/");
+ sal_Int32 len = schemeSpecificPart.getLength();
+ sal_Int32 i = 0;
bool hasAuthority = false;
OUString authority;
- OUString path;
- bool hasQuery = false;
- OUString query;
- if (isHierarchical) {
- sal_Int32 len = schemeSpecificPart.getLength();
- sal_Int32 i = 0;
- if (len - i >= 2 && schemeSpecificPart[i] == '/'
- && schemeSpecificPart[i + 1] == '/')
- {
- i += 2;
- sal_Int32 n = i;
- while (i < len && schemeSpecificPart[i] != '/'
- && schemeSpecificPart[i] != '?') {
- ++i;
- }
- hasAuthority = true;
- authority = schemeSpecificPart.copy(n, i - n);
- }
+ if (len - i >= 2 && schemeSpecificPart[i] == '/'
+ && schemeSpecificPart[i + 1] == '/')
+ {
+ i += 2;
sal_Int32 n = i;
- i = schemeSpecificPart.indexOf('?', i);
- if (i == -1) {
- i = len;
+ while (i < len && schemeSpecificPart[i] != '/'
+ && schemeSpecificPart[i] != '?') {
+ ++i;
}
- path = schemeSpecificPart.copy(n, i - n);
- if (i != len) {
- hasQuery = true;
- query = schemeSpecificPart.copy(i + 1);
- }
- } else {
- if (schemeSpecificPart.isEmpty()) {
- // The scheme-specific part of an opaque URI must not be empty:
- return nullptr;
- }
- path = schemeSpecificPart;
+ hasAuthority = true;
+ authority = schemeSpecificPart.copy(n, i - n);
+ }
+ sal_Int32 n = i;
+ i = schemeSpecificPart.indexOf('?', i);
+ if (i == -1) {
+ i = len;
+ }
+ OUString path = schemeSpecificPart.copy(n, i - n);
+ bool hasQuery = false;
+ OUString query;
+ if (i != len) {
+ hasQuery = true;
+ query = schemeSpecificPart.copy(i + 1);
}
return new UriReference(
- scheme, isHierarchical, hasAuthority, authority, path, hasQuery, query);
+ scheme, hasAuthority, authority, path, hasQuery, query);
}
-void processSegments(
- std::vector<sal_Int32> & segments,
- css::uno::Reference< css::uri::XUriReference > const & uriReference,
- bool base, bool processSpecialSegments)
+struct Segment {
+ bool leadingSlash;
+ bool excessParent;
+ std::u16string_view segment;
+
+ Segment(bool theLeadingSlash, bool theExcessParent, std::u16string_view theSegment):
+ leadingSlash(theLeadingSlash), excessParent(theExcessParent), segment(theSegment) {}
+};
+
+std::pair<std::vector<Segment>, bool> processSegments(
+ std::u16string_view first, std::u16string_view second, bool processSpecialSegments)
{
- sal_Int32 count = uriReference->getPathSegmentCount() - (base ? 1 : 0);
- assert(count <= SAL_MAX_INT32 - 1 && -count >= SAL_MIN_INT32 + 1);
- for (sal_Int32 i = 0; i < count; ++i) {
- if (processSpecialSegments) {
- OUString segment(uriReference->getPathSegment(i));
- if ( segment == "." ) {
- if (!base && i == count - 1) {
- segments.push_back(0);
+ std::vector<Segment> segments;
+ bool processed = false;
+ std::u16string_view const * half = &first;
+ // later checks for `half == &first` and `half == &second` rely on the fact that `first` and
+ // `second` are passed by value, in case a caller passes the same object for both arguments
+ std::size_t index = 0;
+ bool slash = false;
+ if (index == half->length()) {
+ half = &second;
+ index = 0;
+ }
+ if (index != half->length()) {
+ if ((*half)[index] == u'/') {
+ slash = true;
+ ++index;
+ }
+ for (;;) {
+ if (index == half->length() && half == &first) {
+ half = &second;
+ index = 0;
+ }
+ if (index == half->length()) {
+ if (slash) {
+ segments.emplace_back(true, false, std::u16string_view());
}
- continue;
- } else if ( segment == ".." ) {
- if (segments.empty() || std::abs(segments.back()) == 1) {
- segments.push_back(base ? -1 : 1);
- } else {
- segments.pop_back();
+ break;
+ }
+ auto const n = std::min(half->find(u'/', index), half->length());
+ auto const leadingSlash = slash;
+ auto const segment = half->substr(index, n - index);
+ auto const process = processSpecialSegments || half == &second;
+ index = n;
+ slash = false;
+ if (index == half->length() && half == &first) {
+ half = &second;
+ index = 0;
+ }
+ if (index != half->length() && (*half)[index] == u'/') {
+ slash = true;
+ ++index;
+ }
+ if (process) {
+ if (segment == u".") {
+ slash = leadingSlash;
+ processed = true;
+ continue;
+ } else if (segment == u"..") {
+ if (segments.empty() || segments.back().excessParent) {
+ segments.emplace_back(leadingSlash, true, segment);
+ } else {
+ if (leadingSlash) {
+ segments.pop_back();
+ }
+ slash = leadingSlash;
+ }
+ processed = true;
+ continue;
}
- continue;
}
+ segments.emplace_back(leadingSlash, false, segment);
}
- segments.push_back(base ? -(i + 2) : i + 2);
}
+ return {segments, processed};
}
class Factory:
@@ -264,7 +304,7 @@ public:
makeAbsolute(
css::uno::Reference< css::uri::XUriReference > const & baseUriReference,
css::uno::Reference< css::uri::XUriReference > const & uriReference,
- sal_Bool processSpecialBaseSegments,
+ sal_Bool processAdditionalSpecialSegments,
css::uri::RelativeUriExcessParentSegments excessParentSegments) override;
virtual css::uno::Reference< css::uri::XUriReference > SAL_CALL
@@ -373,25 +413,80 @@ css::uno::Reference< css::uri::XUriReference > Factory::parse(
css::uno::Reference< css::uri::XUriReference > Factory::makeAbsolute(
css::uno::Reference< css::uri::XUriReference > const & baseUriReference,
css::uno::Reference< css::uri::XUriReference > const & uriReference,
- sal_Bool processSpecialBaseSegments,
+ sal_Bool processAdditionalSpecialSegments,
css::uri::RelativeUriExcessParentSegments excessParentSegments)
{
if (!baseUriReference.is() || !baseUriReference->isAbsolute()
- || !baseUriReference->isHierarchical() || !uriReference.is()) {
+ || !uriReference.is()) {
return nullptr;
} else if (uriReference->isAbsolute()) {
+ if (processAdditionalSpecialSegments) {
+ auto const path = uriReference->getPath();
+ auto [segments, proc] = processSegments(path, {}, true);
+ if (proc) {
+ OUStringBuffer abs(uriReference->getScheme());
+ abs.append(':');
+ if (uriReference->hasAuthority()) {
+ abs.append("//");
+ abs.append(uriReference->getAuthority());
+ }
+ for (auto const & i : segments)
+ {
+ if (i.excessParent) {
+ switch (excessParentSegments) {
+ case css::uri::RelativeUriExcessParentSegments_ERROR:
+ return nullptr;
+
+ case css::uri::RelativeUriExcessParentSegments_RETAIN:
+ assert(i.segment == u"..");
+ break;
+
+ case css::uri::RelativeUriExcessParentSegments_REMOVE:
+ continue;
+
+ default:
+ assert(false);
+ break;
+ }
+ }
+ if (i.leadingSlash) {
+ abs.append('/');
+ }
+ abs.append(i.segment);
+ }
+ if (uriReference->hasQuery()) {
+ abs.append('?');
+ abs.append(uriReference->getQuery());
+ }
+ if (uriReference->hasFragment()) {
+ abs.append('#');
+ abs.append(uriReference->getFragment());
+ }
+ return parse(abs.makeStringAndClear());
+ }
+ }
return clone(uriReference);
} else if (!uriReference->hasAuthority()
- && uriReference->getPath().isEmpty()
- && !uriReference->hasQuery()) {
- css::uno::Reference< css::uri::XUriReference > abs(
- clone(baseUriReference));
+ && uriReference->getPath().isEmpty()) {
+ OUStringBuffer abs(baseUriReference->getScheme());
+ abs.append(':');
+ if (baseUriReference->hasAuthority()) {
+ abs.append("//");
+ abs.append(baseUriReference->getAuthority());
+ }
+ abs.append(baseUriReference->getPath());
+ if (uriReference->hasQuery()) {
+ abs.append('?');
+ abs.append(uriReference->getQuery());
+ } else if (baseUriReference->hasQuery()) {
+ abs.append('?');
+ abs.append(baseUriReference->getQuery());
+ }
if (uriReference->hasFragment()) {
- abs->setFragment(uriReference->getFragment());
- } else {
- abs->clearFragment();
+ abs.append('#');
+ abs.append(uriReference->getFragment());
}
- return abs;
+ return parse(abs.makeStringAndClear());
} else {
OUStringBuffer abs(baseUriReference->getScheme());
abs.append(':');
@@ -403,73 +498,77 @@ css::uno::Reference< css::uri::XUriReference > Factory::makeAbsolute(
abs.append(baseUriReference->getAuthority());
}
if (uriReference->hasRelativePath()) {
- std::vector<sal_Int32> segments;
- processSegments(
- segments, baseUriReference, true, processSpecialBaseSegments);
- processSegments(segments, uriReference, false, true);
- // If the path component of the base URI reference is empty (which
- // implies that the base URI reference denotes a "root entity"), and
- // the resulting URI reference denotes the same root entity, make
- // sure the path component of the resulting URI reference is also
- // empty (and not "/"). RFC 2396 is unclear about this, and I chose
- // these rules for consistent results.
- bool slash = !baseUriReference->getPath().isEmpty();
- if (slash) {
- abs.append('/');
+ auto path1 = baseUriReference->getPath();
+ if (path1.isEmpty()) {
+ if (baseUriReference->hasAuthority()) {
+ path1 = "/";
+ }
+ } else {
+ path1 = path1.copy(0, path1.lastIndexOf('/') + 1);
}
- for (const auto& i : segments)
+ auto const path2 = uriReference->getPath();
+ auto [segments, _] = processSegments(path1, path2, processAdditionalSpecialSegments);
+ (void)_;
+ for (auto const & i : segments)
{
- if (i < -1) {
- OUString segment(
- baseUriReference->getPathSegment(-(i + 2)));
- if (!segment.isEmpty() || segments.size() > 1) {
- if (!slash) {
- abs.append('/');
- }
- abs.append(segment);
- slash = true;
- abs.append('/');
- }
- } else if (i > 1) {
- OUString segment(uriReference->getPathSegment(i - 2));
- if (!segment.isEmpty() || segments.size() > 1) {
- if (!slash) {
- abs.append('/');
- }
- abs.append(segment);
- slash = false;
- }
- } else if (i == 0) {
- if (segments.size() > 1 && !slash) {
- abs.append('/');
- }
- } else {
+ if (i.excessParent) {
switch (excessParentSegments) {
case css::uri::RelativeUriExcessParentSegments_ERROR:
return nullptr;
case css::uri::RelativeUriExcessParentSegments_RETAIN:
- if (!slash) {
- abs.append('/');
- }
- abs.append("..");
- slash = i < 0;
- if (slash) {
- abs.append('/');
- }
+ assert(i.segment == u"..");
break;
case css::uri::RelativeUriExcessParentSegments_REMOVE:
- break;
+ continue;
default:
assert(false);
break;
}
}
+ if (i.leadingSlash) {
+ abs.append('/');
+ }
+ abs.append(i.segment);
}
} else {
- abs.append(uriReference->getPath());
+ bool processed = false;
+ if (processAdditionalSpecialSegments) {
+ auto const path = uriReference->getPath();
+ auto [segments, proc] = processSegments(path, {}, true);
+ if (proc) {
+ for (auto const & i : segments)
+ {
+ if (i.excessParent) {
+ switch (excessParentSegments) {
+ case css::uri::RelativeUriExcessParentSegments_ERROR:
+ return nullptr;
+
+ case css::uri::RelativeUriExcessParentSegments_RETAIN:
+ assert(i.segment == u"..");
+ break;
+
+ case css::uri::RelativeUriExcessParentSegments_REMOVE:
+ continue;
+
+ default:
+ assert(false);
+ break;
+ }
+ }
+ if (i.leadingSlash) {
+ abs.append('/');
+ }
+ abs.append(i.segment);
+ }
+ processed = true;
+ }
+ }
+ if (!processed) {
+ abs.append(uriReference->getPath());
+ }
}
if (uriReference->hasQuery()) {
abs.append('?');
@@ -491,9 +590,9 @@ css::uno::Reference< css::uri::XUriReference > Factory::makeRelative(
sal_Bool encodeRetainedSpecialSegments)
{
if (!baseUriReference.is() || !baseUriReference->isAbsolute()
- || !baseUriReference->isHierarchical() || !uriReference.is()) {
+ || !uriReference.is()) {
return nullptr;
- } else if (!uriReference->isAbsolute() || !uriReference->isHierarchical()
+ } else if (!uriReference->isAbsolute() || uriReference->hasRelativePath()
|| !baseUriReference->getScheme().equalsIgnoreAsciiCase(
uriReference->getScheme())) {
return clone(uriReference);
@@ -512,8 +611,8 @@ css::uno::Reference< css::uri::XUriReference > Factory::makeRelative(
rel.append(uriReference->getPath());
} else if ((equalIgnoreEscapeCase(
baseUriReference->getPath(), uriReference->getPath())
- || (baseUriReference->getPath().getLength() <= 1
- && uriReference->getPath().getLength() <= 1))
+ || (baseUriReference->getPath() == "/"
+ && uriReference->getPath().isEmpty()))
&& baseUriReference->hasQuery() == uriReference->hasQuery()
&& equalIgnoreEscapeCase(
baseUriReference->getQuery(), uriReference->getQuery()))
@@ -533,24 +632,30 @@ css::uno::Reference< css::uri::XUriReference > Factory::makeRelative(
break;
}
}
- if (i == 0 && preferAbsoluteOverRelativePath
+ if (i == 0
+ && (preferAbsoluteOverRelativePath || uriReference->hasQuery())
&& (preferAuthorityOverRelativePath
|| !uriReference->getPath().startsWith("//")))
{
- if (baseUriReference->getPath().getLength() > 1
- || uriReference->getPath().getLength() > 1)
- {
- if (uriReference->getPath().isEmpty()) {
+ if (uriReference->getPath().isEmpty()) {
+ if (!baseUriReference->getPath().isEmpty()
+ && baseUriReference->getPath() != "/")
+ {
rel.append('/');
- } else {
- assert(uriReference->getPath()[0] == '/');
- if (uriReference->getPath().startsWith("//")) {
- assert(uriReference->hasAuthority());
- rel.append("//");
- rel.append(uriReference->getAuthority());
- }
- rel.append(uriReference->getPath());
}
+ } else if (uriReference->getPath() == "/") {
+ if (baseUriReference->getPath().isEmpty()
+ || baseUriReference->getPath() != "/")
+ {
+ rel.append('/');
+ }
+ } else {
+ if (uriReference->getPath().startsWith("//")) {
+ assert(uriReference->hasAuthority());
+ rel.append("//");
+ rel.append(uriReference->getAuthority());
+ }
+ rel.append(uriReference->getPath());
}
} else {
bool segments = false;
diff --git a/stoc/source/uriproc/UriSchemeParser_vndDOTsunDOTstarDOTexpand.cxx b/stoc/source/uriproc/UriSchemeParser_vndDOTsunDOTstarDOTexpand.cxx
index 105d00bb1e80..cebe754cbaaa 100644
--- a/stoc/source/uriproc/UriSchemeParser_vndDOTsunDOTstarDOTexpand.cxx
+++ b/stoc/source/uriproc/UriSchemeParser_vndDOTsunDOTstarDOTexpand.cxx
@@ -56,7 +56,7 @@ class UrlReference:
public:
UrlReference(OUString const & scheme, OUString const & path):
base_(
- scheme, false, false, OUString(), path, false,
+ scheme, false, OUString(), path, false,
OUString())
{}
diff --git a/stoc/source/uriproc/UriSchemeParser_vndDOTsunDOTstarDOTscript.cxx b/stoc/source/uriproc/UriSchemeParser_vndDOTsunDOTstarDOTscript.cxx
index 2f4cb9e09071..1191a711262f 100644
--- a/stoc/source/uriproc/UriSchemeParser_vndDOTsunDOTstarDOTscript.cxx
+++ b/stoc/source/uriproc/UriSchemeParser_vndDOTsunDOTstarDOTscript.cxx
@@ -191,7 +191,7 @@ class UrlReference:
public:
UrlReference(OUString const & scheme, OUString const & path):
m_base(
- scheme, false, false, OUString(), path, false, OUString())
+ scheme, false, OUString(), path, false, OUString())
{}
UrlReference(const UrlReference&) = delete;
diff --git a/stoc/test/uriproc/test_uriproc.cxx b/stoc/test/uriproc/test_uriproc.cxx
index a3f45a98476d..f30913c2841f 100644
--- a/stoc/test/uriproc/test_uriproc.cxx
+++ b/stoc/test/uriproc/test_uriproc.cxx
@@ -167,8 +167,8 @@ void Test::testParse() {
Data data[] = {
{ "", nullptr, "", true, nullptr,
"", true, 0, "", "", "", "", "", nullptr, nullptr },
- { "scheme:", nullptr, nullptr, false, nullptr,
- nullptr, false, 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr },
+ { "scheme:", "scheme", "", false, nullptr,
+ "", true, 0, "", "", "", "", "", nullptr, nullptr },
{ "scheme:/", "scheme", "/", true, nullptr,
"/", false, 1, "", "", "", "", "", nullptr, nullptr },
{ "scheme://", "scheme", "//", true, "",
@@ -179,10 +179,10 @@ void Test::testParse() {
"//", false, 2, "", "", "", "", "", nullptr, nullptr },
{ "scheme:////", "scheme", "////", true, "",
"//", false, 2, "", "", "", "", "", nullptr, nullptr },
- { "scheme:#", nullptr, nullptr, false, nullptr,
- nullptr, false, 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr },
+ { "scheme:#", "scheme", "", false, nullptr,
+ "", true, 0, "", "", "", "", "", nullptr, "" },
{ "scheme:?", "scheme", "?", false, nullptr,
- "?", false, 0, "", "", "", "", "", nullptr, nullptr },
+ "", true, 0, "", "", "", "", "", "", nullptr },
{ "/", nullptr, "/", true, nullptr,
"/", false, 1, "", "", "", "", "", nullptr, nullptr },
{ "//", nullptr, "//", true, "",
@@ -293,7 +293,7 @@ void Test::testMakeAbsolute() {
char const * absolute;
};
Data data[] = {
- // The following tests are taken from RFC 2396, Appendix C:
+ // The following tests are taken from RFC 3986, Section 5.4:
{ "http://a/b/c/d;p?q", "g:h", true,
css::uri::RelativeUriExcessParentSegments_ERROR, "g:h" },
{ "http://a/b/c/d;p?q", "g", true,
@@ -307,7 +307,7 @@ void Test::testMakeAbsolute() {
{ "http://a/b/c/d;p?q", "//g", true,
css::uri::RelativeUriExcessParentSegments_ERROR, "http://g" },
{ "http://a/b/c/d;p?q", "?y", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/?y" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/d;p?y" },
{ "http://a/b/c/d;p?q", "g?y", true,
css::uri::RelativeUriExcessParentSegments_ERROR,
"http://a/b/c/g?y" },
@@ -328,6 +328,9 @@ void Test::testMakeAbsolute() {
{ "http://a/b/c/d;p?q", "g;x?y#s", true,
css::uri::RelativeUriExcessParentSegments_ERROR,
"http://a/b/c/g;x?y#s" },
+ { "http://a/b/c/d;p?q", "", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR,
+ "http://a/b/c/d;p?q" },
{ "http://a/b/c/d;p?q", ".", true,
css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/" },
{ "http://a/b/c/d;p?q", "./", true,
@@ -344,9 +347,6 @@ void Test::testMakeAbsolute() {
css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/" },
{ "http://a/b/c/d;p?q", "../../g", true,
css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/g" },
- { "http://a/b/c/d;p?q", "", true,
- css::uri::RelativeUriExcessParentSegments_ERROR,
- "http://a/b/c/d;p?q" },
{ "http://a/b/c/d;p?q", "../../../g", true,
css::uri::RelativeUriExcessParentSegments_ERROR, nullptr },
{ "http://a/b/c/d;p?q", "../../../g", true,
@@ -361,9 +361,13 @@ void Test::testMakeAbsolute() {
{ "http://a/b/c/d;p?q", "../../../../g", true,
css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/g" },
{ "http://a/b/c/d;p?q", "/./g", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/./g" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/g" },
{ "http://a/b/c/d;p?q", "/../g", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/../g" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, nullptr },
+ { "http://a/b/c/d;p?q", "/../g", true,
+ css::uri::RelativeUriExcessParentSegments_RETAIN, "http://a/../g" },
+ { "http://a/b/c/d;p?q", "/../g", true,
+ css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/g" },
{ "http://a/b/c/d;p?q", "g.", true,
css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/g." },
{ "http://a/b/c/d;p?q", ".g", true,
@@ -403,48 +407,91 @@ void Test::testMakeAbsolute() {
{ "http://a/b/c/d;p?q", "http:g", true,
css::uri::RelativeUriExcessParentSegments_ERROR, "http:g" },
+ { "scheme:", "", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:" },
+ { "scheme:", ".", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:" },
+ { "scheme:", "./", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:" },
+ { "scheme:", "./.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:" },
+ { "scheme:", "././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:" },
+ { "scheme:", "././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:" },
+ { "scheme:", "x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:", "x/../", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:", "x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:", "x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:", "x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:", "x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:", "x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:", "./x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:", "././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:", "./././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:", "./x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:", "./x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:", "././x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:", "././x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:", "./././x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+
{ "scheme://a", "", true,
css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
{ "scheme://a", ".", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
{ "scheme://a", "./", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
{ "scheme://a", "./.", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
{ "scheme://a", "././", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
{ "scheme://a", "././.", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
{ "scheme://a", "x/..", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
{ "scheme://a", "x/../", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
{ "scheme://a", "x/../.", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
{ "scheme://a", "x/.././", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
{ "scheme://a", "x/.././.", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
{ "scheme://a", "x/../././", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
{ "scheme://a", "x/../././.", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
{ "scheme://a", "./x/..", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
{ "scheme://a", "././x/..", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
{ "scheme://a", "./././x/..", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
{ "scheme://a", "./x/../.", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
{ "scheme://a", "./x/.././", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
{ "scheme://a", "././x/.././.", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
{ "scheme://a", "././x/../././", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
{ "scheme://a", "./././x/../././.", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
{ "scheme://a/", "", true,
css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
@@ -575,6 +622,350 @@ void Test::testMakeAbsolute() {
{ "scheme://a/b/", "./././x/../././.", true,
css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+ { "scheme:a", "", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a" },
+ { "scheme:a", ".", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:" },
+ { "scheme:a", "./", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:" },
+ { "scheme:a", "./.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:" },
+ { "scheme:a", "././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:" },
+ { "scheme:a", "././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:" },
+ { "scheme:a", "x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:a", "x/../", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:a", "x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:a", "x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:a", "x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:a", "x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:a", "x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:a", "./x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:a", "././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:a", "./././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:a", "./x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:a", "./x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:a", "././x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:a", "././x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:a", "./././x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+
+ { "scheme:a/", "", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/", ".", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/", "./", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/", "./.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/", "././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/", "././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/", "x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/", "x/../", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/", "x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/", "x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/", "x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/", "x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/", "x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/", "./x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/", "././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/", "./././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/", "./x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/", "./x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/", "././x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/", "././x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/", "./././x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+
+ { "scheme:a/b", "", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b" },
+ { "scheme:a/b", ".", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/b", "./", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/b", "./.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/b", "././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/b", "././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/b", "x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/b", "x/../", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/b", "x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/b", "x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/b", "x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/b", "x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/b", "x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/b", "./x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/b", "././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/b", "./././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/b", "./x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/b", "./x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/b", "././x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/b", "././x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+ { "scheme:a/b", "./././x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/" },
+
+ { "scheme:a/b/", "", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b/" },
+ { "scheme:a/b/", ".", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b/" },
+ { "scheme:a/b/", "./", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b/" },
+ { "scheme:a/b/", "./.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b/" },
+ { "scheme:a/b/", "././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b/" },
+ { "scheme:a/b/", "././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b/" },
+ { "scheme:a/b/", "x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b/" },
+ { "scheme:a/b/", "x/../", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b/" },
+ { "scheme:a/b/", "x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b/" },
+ { "scheme:a/b/", "x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b/" },
+ { "scheme:a/b/", "x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b/" },
+ { "scheme:a/b/", "x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b/" },
+ { "scheme:a/b/", "x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b/" },
+ { "scheme:a/b/", "./x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b/" },
+ { "scheme:a/b/", "././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b/" },
+ { "scheme:a/b/", "./././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b/" },
+ { "scheme:a/b/", "./x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b/" },
+ { "scheme:a/b/", "./x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b/" },
+ { "scheme:a/b/", "././x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b/" },
+ { "scheme:a/b/", "././x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b/" },
+ { "scheme:a/b/", "./././x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:a/b/" },
+
+ { "scheme:/a", "", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a" },
+ { "scheme:/a", ".", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:/a", "./", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:/a", "./.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:/a", "././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:/a", "././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:/a", "x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:/a", "x/../", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:/a", "x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:/a", "x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:/a", "x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:/a", "x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:/a", "x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:/a", "./x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:/a", "././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:/a", "./././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:/a", "./x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:/a", "./x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:/a", "././x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:/a", "././x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+ { "scheme:/a", "./././x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/" },
+
+ { "scheme:/a/", "", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/", ".", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/", "./", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/", "./.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/", "././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/", "././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/", "x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/", "x/../", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/", "x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/", "x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/", "x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/", "x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/", "x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/", "./x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/", "././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/", "./././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/", "./x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/", "./x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/", "././x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/", "././x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/", "./././x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+
+ { "scheme:/a/b", "", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b" },
+ { "scheme:/a/b", ".", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/b", "./", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/b", "./.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/b", "././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/b", "././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/b", "x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/b", "x/../", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/b", "x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/b", "x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/b", "x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/b", "x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/b", "x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/b", "./x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/b", "././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/b", "./././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/b", "./x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/b", "./x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/b", "././x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/b", "././x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+ { "scheme:/a/b", "./././x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/" },
+
+ { "scheme:/a/b/", "", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b/" },
+ { "scheme:/a/b/", ".", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b/" },
+ { "scheme:/a/b/", "./", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b/" },
+ { "scheme:/a/b/", "./.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b/" },
+ { "scheme:/a/b/", "././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b/" },
+ { "scheme:/a/b/", "././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b/" },
+ { "scheme:/a/b/", "x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b/" },
+ { "scheme:/a/b/", "x/../", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b/" },
+ { "scheme:/a/b/", "x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b/" },
+ { "scheme:/a/b/", "x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b/" },
+ { "scheme:/a/b/", "x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b/" },
+ { "scheme:/a/b/", "x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b/" },
+ { "scheme:/a/b/", "x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b/" },
+ { "scheme:/a/b/", "./x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b/" },
+ { "scheme:/a/b/", "././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b/" },
+ { "scheme:/a/b/", "./././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b/" },
+ { "scheme:/a/b/", "./x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b/" },
+ { "scheme:/a/b/", "./x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b/" },
+ { "scheme:/a/b/", "././x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b/" },
+ { "scheme:/a/b/", "././x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b/" },
+ { "scheme:/a/b/", "./././x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme:/a/b/" },
+
{ "scheme://a#s", "", true,
css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
{ "scheme://a", "?q", true,
@@ -584,7 +975,10 @@ void Test::testMakeAbsolute() {
{ "scheme://a", "#s", true,
css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a#s" },
{ "scheme://a#s1", "#s2", true,
- css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a#s2" } };
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a#s2" },
+
+ { "schema://a", "schema://b/c/../d", true, css::uri::RelativeUriExcessParentSegments_ERROR,
+ "schema://b/d" } };
for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
css::uno::Reference< css::uri::XUriReference > baseUriRef(
m_uriFactory->parse(
@@ -632,20 +1026,20 @@ void Test::testMakeRelative() {
"scheme://a/b/e?q#s" },
{ "scheme://a/b", "scheme://a?q", true, true, false, "/?q",
"scheme://a/?q" },
- { "scheme://a/b", "scheme://a?q", true, false, false, "?q",
+ { "scheme://a/b", "scheme://a?q", true, false, false, "/?q",
"scheme://a/?q" },
{ "scheme://a", "scheme://a?q", true, true, false, "?q", nullptr },
{ "scheme://a/", "scheme://a?q", true, true, false, "?q",
"scheme://a/?q" },
- { "scheme://a", "scheme://a/?q", true, true, false, "?q",
- "scheme://a?q" },
+ { "scheme://a", "scheme://a/?q", true, true, false, "/?q",
+ nullptr },
{ "scheme://a/", "scheme://a/?q", true, true, false, "?q",
nullptr },
{ "scheme://a?q", "scheme://a?q", true, true, false, "", nullptr },
{ "scheme://a/?q", "scheme://a?q", true, true, false, "",
"scheme://a/?q" },
- { "scheme://a?q", "scheme://a/?q", true, true, false, "",
- "scheme://a?q" },
+ { "scheme://a?q", "scheme://a/?q", true, true, false, "/?q",
+ nullptr },
{ "scheme://a/?q", "scheme://a/?q", true, true, false, "", nullptr },
{ "scheme://a/b/c/d", "scheme://a//", true, true, false, "//a//", nullptr },
{ "scheme://a/b/c/d", "scheme://a//", false, true, false, "../..//",
@@ -689,7 +1083,13 @@ void Test::testMakeRelative() {
{ "scheme://auth/a/b", "scheme://auth/c/d", true, true, false, "/c/d",
nullptr },
{ "scheme://auth/a/b", "scheme://auth/c/d", true, false, false,
- "../c/d", nullptr } };
+ "../c/d", nullptr },
+ { "scheme:a/b/c", "scheme://d/e/f", true, true, false, "//d/e/f", nullptr },
+ { "scheme:/a/b/c", "scheme://d/e/f", true, true, false, "//d/e/f", nullptr },
+ { "scheme:a/b/c", "scheme:/d/e/f", true, true, false, "/d/e/f", nullptr },
+ { "scheme:/a/b/c", "scheme:/d/e/f", true, true, false, "/d/e/f", nullptr },
+ { "scheme:a/b/c", "scheme:d/e/f", true, true, false, "scheme:d/e/f", nullptr },
+ { "scheme:/a/b/c", "scheme:d/e/f", true, true, false, "scheme:d/e/f", nullptr } };
for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
css::uno::Reference< css::uri::XUriReference > baseUriRef(
m_uriFactory->parse(