From d739b01b9f20b1a7fd4b313b28e4dd4e5edd9193 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Sat, 1 Mar 2014 19:25:38 +0100 Subject: Adapt rtl_uriConvertRelToAbs to RFC 3986 ...which updates RFC 2396, removes the requirement that the base URI's path starts with a slash, and clarifies how to treat excess "." and ".." segments. This nicely allows handling of those odd vnd.sun.star.Package URLs as intended now, so that making absolute relative to base URL yields instead of provoking a MalformedUriException. Change-Id: Ice84303a57698a2c05d3a45541fe78b67450fa3c --- sal/qa/rtl/uri/rtl_testuri.cxx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'sal/qa') diff --git a/sal/qa/rtl/uri/rtl_testuri.cxx b/sal/qa/rtl/uri/rtl_testuri.cxx index b230d4303b22..fce4aa5d0c5d 100644 --- a/sal/qa/rtl/uri/rtl_testuri.cxx +++ b/sal/qa/rtl/uri/rtl_testuri.cxx @@ -279,14 +279,14 @@ void Test::test_Uri() { char const * pAbs; }; static RelToAbsTest const aRelToAbsTest[] - = { // The following tests are taken from RFC 2396: + = { // The following tests are taken from RFC 3986: { "http://a/b/c/d;p?q", "g:h", "g:h" }, { "http://a/b/c/d;p?q", "g", "http://a/b/c/g" }, { "http://a/b/c/d;p?q", "./g", "http://a/b/c/g" }, { "http://a/b/c/d;p?q", "g/", "http://a/b/c/g/" }, { "http://a/b/c/d;p?q", "/g", "http://a/g" }, { "http://a/b/c/d;p?q", "//g", "http://g" }, - { "http://a/b/c/d;p?q", "?y", "http://a/b/c/?y" }, + { "http://a/b/c/d;p?q", "?y", "http://a/b/c/d;p?y" }, { "http://a/b/c/d;p?q", "g?y", "http://a/b/c/g?y" }, { "http://a/b/c/d;p?q", "#s", "http://a/b/c/d;p?q#s" }, { "http://a/b/c/d;p?q", "g#s", "http://a/b/c/g#s" }, @@ -294,6 +294,7 @@ void Test::test_Uri() { { "http://a/b/c/d;p?q", ";x", "http://a/b/c/;x" }, { "http://a/b/c/d;p?q", "g;x", "http://a/b/c/g;x" }, { "http://a/b/c/d;p?q", "g;x?y#s", "http://a/b/c/g;x?y#s" }, + { "http://a/b/c/d;p?q", "", "http://a/b/c/d;p?q" }, { "http://a/b/c/d;p?q", ".", "http://a/b/c/" }, { "http://a/b/c/d;p?q", "./", "http://a/b/c/" }, { "http://a/b/c/d;p?q", "..", "http://a/b/" }, @@ -302,11 +303,10 @@ void Test::test_Uri() { { "http://a/b/c/d;p?q", "../..", "http://a/" }, { "http://a/b/c/d;p?q", "../../", "http://a/" }, { "http://a/b/c/d;p?q", "../../g", "http://a/g" }, - { "http://a/b/c/d;p?q", "", "http://a/b/c/d;p?q" }, - { "http://a/b/c/d;p?q", "../../../g", "http://a/../g" }, - { "http://a/b/c/d;p?q", "../../../../g", "http://a/../../g" }, - { "http://a/b/c/d;p?q", "/./g", "http://a/./g" }, - { "http://a/b/c/d;p?q", "/../g", "http://a/../g" }, + { "http://a/b/c/d;p?q", "../../../g", "http://a/g" }, + { "http://a/b/c/d;p?q", "../../../../g", "http://a/g" }, + { "http://a/b/c/d;p?q", "/./g", "http://a/g" }, + { "http://a/b/c/d;p?q", "/../g", "http://a/g" }, { "http://a/b/c/d;p?q", "g.", "http://a/b/c/g." }, { "http://a/b/c/d;p?q", ".g", "http://a/b/c/.g" }, { "http://a/b/c/d;p?q", "g..", "http://a/b/c/g.." }, @@ -322,13 +322,15 @@ void Test::test_Uri() { { "http://a/b/c/d;p?q", "g#s/./x", "http://a/b/c/g#s/./x" }, { "http://a/b/c/d;p?q", "g#s/../x", "http://a/b/c/g#s/../x" }, { "http://a/b/c/d;p?q", "http:g", "http:g" }, + { "http!://a/b/c/d;p?q", "g:h", "g:h" }, { "http!://a/b/c/d;p?q", "g", 0 }, { "http:b/c/d;p?q", "g:h", "g:h" }, - { "http:b/c/d;p?q", "g", 0 }, - { "http://a/b/../", "../c", "http://a/b/../../c" }, + { "http:b/c/d;p?q", "g", "http:b/c/g" }, + { "http://a/b/../", "../c", "http://a/c" }, { "http://a/b/..", "../c", "http://a/c" }, - { "http://a/./b/", ".././.././../c", "http://a/./../../c" } }; + { "http://a/./b/", ".././.././../c", "http://a/c" }, + { "http://a", "b", "http://a/b" } }; for (std::size_t i = 0; i < sizeof aRelToAbsTest / sizeof (RelToAbsTest); ++i) { rtl::OUString aAbs; -- cgit