[Libreoffice-commits] core.git: Branch 'libreoffice-4-0' - tools/qa tools/source
Stephan Bergmann
sbergman at redhat.com
Fri Jul 26 11:23:54 PDT 2013
tools/qa/cppunit/test_urlobj.cxx | 22 ++++++++++++++++++++++
tools/source/fsys/urlobj.cxx | 4 ++--
2 files changed, 24 insertions(+), 2 deletions(-)
New commits:
commit ffcc71001927a862be0fdd9f27099b5468c7b37b
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Jul 26 17:41:08 2013 +0200
fdo#33605: Handle http etc. URLs with no path but fragment
Change-Id: I8c47cc55e7ad53e514c0bd46130cbbe6a1bb0357
(cherry picked from commit 44ddacb232c4fd5cbb28867aa28d7d855788a511)
Reviewed-on: https://gerrit.libreoffice.org/5130
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Eike Rathke <erack at redhat.com>
diff --git a/tools/qa/cppunit/test_urlobj.cxx b/tools/qa/cppunit/test_urlobj.cxx
index 38120aa..07714ee 100644
--- a/tools/qa/cppunit/test_urlobj.cxx
+++ b/tools/qa/cppunit/test_urlobj.cxx
@@ -268,6 +268,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.
@@ -280,6 +301,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 f6e9db4..eecc4b4 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -2942,7 +2942,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)
{
@@ -2962,7 +2962,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)
More information about the Libreoffice-commits
mailing list