summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-01-15 11:33:10 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-01-15 10:52:56 +0100
commit6b973753d407d66dfa5fda86547246c486ab7087 (patch)
tree72534f1829bfd5f4d7b72de7ee0368dc44b785ff /framework
parentbe27b6f0bb73128ad4970fc5649c93d546822a84 (diff)
tdf#146754: consider xyz:123 as host:port when parsing URLs smart
... rather than scheme: and path. Change-Id: I9a48310b585b8fa3e31635f877a91f1560b065f0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128457 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'framework')
-rw-r--r--framework/qa/cppunit/services.cxx24
1 files changed, 24 insertions, 0 deletions
diff --git a/framework/qa/cppunit/services.cxx b/framework/qa/cppunit/services.cxx
index c75ce9f65633..873ea5938e4c 100644
--- a/framework/qa/cppunit/services.cxx
+++ b/framework/qa/cppunit/services.cxx
@@ -14,6 +14,7 @@
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/frame/XComponentLoader.hpp>
#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/util/URLTransformer.hpp>
#include <comphelper/propertyvalue.hxx>
#include <salhelper/thread.hxx>
@@ -126,6 +127,29 @@ CPPUNIT_TEST_FIXTURE(Test, testLoadComponentFromURL)
xThread->join();
}
}
+
+CPPUNIT_TEST_FIXTURE(Test, testURLTransformer_parseSmart)
+{
+ // Without the accompanying fix in place, this test would have failed with
+ // "www.example.com:" treated as scheme, "/8080/foo/" as path, "bar?q=baz"
+ // as name, and "F" as fragment.
+
+ css::util::URL aURL;
+ aURL.Complete = "www.example.com:8080/foo/bar?q=baz#F";
+ css::uno::Reference xParser(css::util::URLTransformer::create(mxComponentContext));
+ CPPUNIT_ASSERT(xParser->parseSmart(aURL, "http:"));
+ CPPUNIT_ASSERT_EQUAL(OUString("http://www.example.com:8080/foo/bar?q=baz#F"), aURL.Complete);
+ CPPUNIT_ASSERT_EQUAL(OUString("http://www.example.com:8080/foo/bar"), aURL.Main);
+ CPPUNIT_ASSERT_EQUAL(OUString("http://"), aURL.Protocol);
+ CPPUNIT_ASSERT(aURL.User.isEmpty());
+ CPPUNIT_ASSERT(aURL.Password.isEmpty());
+ CPPUNIT_ASSERT_EQUAL(OUString("www.example.com"), aURL.Server);
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(8080), aURL.Port);
+ CPPUNIT_ASSERT_EQUAL(OUString("/foo/"), aURL.Path);
+ CPPUNIT_ASSERT_EQUAL(OUString("bar"), aURL.Name);
+ CPPUNIT_ASSERT_EQUAL(OUString("q=baz"), aURL.Arguments);
+ CPPUNIT_ASSERT_EQUAL(OUString("F"), aURL.Mark);
+}
}
CPPUNIT_PLUGIN_IMPLEMENT();