obj.GetMainURL(INetURLObject::DecodeMechanism::NONE));
}
+ void testIsExoticProtocol() {
+ {
+ INetURLObject url(u"vnd.sun.star.pkg://slot%3A0");
+ CPPUNIT_ASSERT_EQUAL(INetProtocol::VndSunStarPkg, url.GetProtocol());
+ CPPUNIT_ASSERT(url.IsExoticProtocol());
+ }
+ {
+ INetURLObject url(u"vnd.sun.star.pkg://vnd.sun.star.pkg%3A%2F%2Fslot%253A0");
+ CPPUNIT_ASSERT_EQUAL(INetProtocol::VndSunStarPkg, url.GetProtocol());
+ CPPUNIT_ASSERT(url.IsExoticProtocol());
+ }
+ {
+ INetURLObject url(u"vnd.sun.star.pkg://http%3A%2F%2Fexample.net");
+ CPPUNIT_ASSERT_EQUAL(INetProtocol::VndSunStarPkg, url.GetProtocol());
+ CPPUNIT_ASSERT(!url.IsExoticProtocol());
+ }
+ {
+ INetURLObject url(u"vnd.sun.star.zip://slot%3A0");
+ CPPUNIT_ASSERT_EQUAL(INetProtocol::Generic, url.GetProtocol());
+ CPPUNIT_ASSERT(url.IsExoticProtocol());
+ }
+ {
+ INetURLObject url(u"vnd.sun.star.zip://slot%3A0/foo");
+ CPPUNIT_ASSERT_EQUAL(INetProtocol::Generic, url.GetProtocol());
+ CPPUNIT_ASSERT(url.IsExoticProtocol());
+ }
+ {
+ INetURLObject url(u"vnd.sun.star.zip://slot%3A0?foo");
+ CPPUNIT_ASSERT_EQUAL(INetProtocol::Generic, url.GetProtocol());
+ CPPUNIT_ASSERT(url.IsExoticProtocol());
+ }
+ {
+ INetURLObject url(u"vnd.sun.star.zip://slot%3A0#foo");
+ CPPUNIT_ASSERT_EQUAL(INetProtocol::Generic, url.GetProtocol());
+ CPPUNIT_ASSERT(url.IsExoticProtocol());
+ }
+ {
+ INetURLObject url(u"vnd.sun.star.zip://http%3A%2F%2Fexample.net");
+ CPPUNIT_ASSERT_EQUAL(INetProtocol::Generic, url.GetProtocol());
+ CPPUNIT_ASSERT(!url.IsExoticProtocol());
+ }
+ }
+
// 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.
CPPUNIT_TEST( urlobjTest_isAnyKnownWebDAVScheme );
CPPUNIT_TEST( testSetName );
CPPUNIT_TEST( testSetExtension );
+ CPPUNIT_TEST( testIsExoticProtocol );
CPPUNIT_TEST_SUITE_END( );
}; // class createPool
{
return true;
}
- if (isSchemeEqualTo(u"vnd.sun.star.pkg") || isSchemeEqualTo(u"vnd.sun.star.zip"))
+ if (m_eScheme == INetProtocol::VndSunStarPkg) {
+ return INetURLObject(GetHost(INetURLObject::DecodeMechanism::WithCharset))
+ .IsExoticProtocol();
+ }
+ if (isSchemeEqualTo(u"vnd.sun.star.zip"))
{
- OUString sPayloadURL = GetURLPath(INetURLObject::DecodeMechanism::WithCharset);
- return sPayloadURL.startsWith(u"//") && INetURLObject(sPayloadURL.subView(2)).IsExoticProtocol();
+ OUString sPayloadURL = GetURLPath(INetURLObject::DecodeMechanism::NONE);
+ if (!sPayloadURL.startsWith(u"//")) {
+ return false;
+ }
+ auto const find = [&sPayloadURL](auto c) {
+ auto const n = sPayloadURL.indexOf(c, 2);
+ return n == -1 ? sPayloadURL.getLength() : n;
+ };
+ return INetURLObject(decode(sPayloadURL.copy(2, std::min(find('/'), find('?')) - 2), INetURLObject::DecodeMechanism::WithCharset)).IsExoticProtocol();
}
return false;
}