summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/qa/cppunit/test_urlobj.cxx22
-rw-r--r--tools/source/fsys/urlobj.cxx4
2 files changed, 24 insertions, 2 deletions
diff --git a/tools/qa/cppunit/test_urlobj.cxx b/tools/qa/cppunit/test_urlobj.cxx
index 6719fc8d2030..6b0b3133bd34 100644
--- a/tools/qa/cppunit/test_urlobj.cxx
+++ b/tools/qa/cppunit/test_urlobj.cxx
@@ -240,6 +240,27 @@ namespace tools_urlobj
}
}
+ void urlobjTest_emptyPath() {
+ {
+ INetURLObject url(OUString("http://example.com"));
+ CPPUNIT_ASSERT_EQUAL(INET_PROT_HTTP, url.GetProtocol());
+ CPPUNIT_ASSERT_EQUAL(OUString("example.com"), url.GetHost());
+ CPPUNIT_ASSERT_EQUAL(OUString("/"), url.GetURLPath());
+ }
+ {
+ // This is an invalid http URL per RFC 2616:
+ INetURLObject url(OUString("http://example.com?query"));
+ CPPUNIT_ASSERT(url.HasError());
+ }
+ {
+ INetURLObject url(OUString("http://example.com#fragment"));
+ CPPUNIT_ASSERT_EQUAL(INET_PROT_HTTP, url.GetProtocol());
+ CPPUNIT_ASSERT_EQUAL(OUString("example.com"), url.GetHost());
+ CPPUNIT_ASSERT_EQUAL(OUString("/"), url.GetURLPath());
+ CPPUNIT_ASSERT_EQUAL(OUString("fragment"), url.GetMark());
+ }
+ }
+
// Change the following lines only, if you add, remove or rename
// member functions of the current class,
// because these macros are need by auto register mechanism.
@@ -252,6 +273,7 @@ namespace tools_urlobj
CPPUNIT_TEST( urlobjTest_005 );
CPPUNIT_TEST( urlobjTest_006 );
CPPUNIT_TEST( urlobjCmisTest );
+ CPPUNIT_TEST( urlobjTest_emptyPath );
CPPUNIT_TEST_SUITE_END( );
}; // class createPool
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 77128d71b1e9..fe719f568091 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -2933,7 +2933,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme,
case INET_PROT_FTP:
case INET_PROT_IMAP:
- if (pPos < pEnd && *pPos != '/')
+ if (pPos < pEnd && *pPos != '/' && *pPos != nFragmentDelimiter)
return false;
while (pPos < pEnd && *pPos != nFragmentDelimiter)
{
@@ -2953,7 +2953,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme,
case INET_PROT_HTTPS:
case INET_PROT_SMB:
case INET_PROT_CMIS:
- if (pPos < pEnd && *pPos != '/')
+ if (pPos < pEnd && *pPos != '/' && *pPos != nFragmentDelimiter)
return false;
while (pPos < pEnd && *pPos != nQueryDelimiter
&& *pPos != nFragmentDelimiter)