diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2021-09-13 13:20:51 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-11-01 18:16:23 +0100 |
commit | 617fbb5fd39e668453588d1b72bfc92a9c648552 (patch) | |
tree | 124fd377dcd419dbe7bcd9cb3fcd7f701698affb | |
parent | a48ccb4c14664e23fbb2c8c1603c82772e5e476e (diff) |
ucb: webdav-curl: implement CurlUri, partially based on SerfUri
The curl_url* functions exist since 7.62.0 and CURLOPT_CURLU since
7.63.0.
Change-Id: I8bc766221636eb3ff0d33ae5a90d00c1bc7ecd7a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122046
Tested-by: Michael Stahl <michael.stahl@allotropia.de>
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | include/sal/log-areas.dox | 1 | ||||
-rw-r--r-- | ucb/Library_ucpdav1.mk | 1 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-curl/ContentProperties.cxx | 4 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-curl/CurlUri.cxx | 285 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-curl/CurlUri.hxx | 87 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx | 10 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-curl/DAVResourceAccess.hxx | 4 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-curl/DAVSessionFactory.cxx | 6 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-curl/webdavcontent.cxx | 26 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-curl/webdavdatasupplier.cxx | 10 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-curl/webdavprovider.hxx | 4 |
12 files changed, 407 insertions, 33 deletions
diff --git a/configure.ac b/configure.ac index a21c8ec9bc60..2c7ed9fb3aec 100644 --- a/configure.ac +++ b/configure.ac @@ -10284,7 +10284,7 @@ if test "$enable_curl" = "yes" -a "$with_system_curl" = "yes"; then SYSTEM_CURL=TRUE # First try PKGCONFIG and then fall back - PKG_CHECK_MODULES(CURL, libcurl >= 7.19.4,, [:]) + PKG_CHECK_MODULES(CURL, libcurl >= 7.63.0,, [:]) if test -n "$CURL_PKG_ERRORS"; then AC_PATH_PROG(CURLCONFIG, curl-config) diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox index aa3e64d793bd..55f15022f340 100644 --- a/include/sal/log-areas.dox +++ b/include/sal/log-areas.dox @@ -432,6 +432,7 @@ certain functionality. @li @c ucb.ucp.ftp @li @c ucb.ucp.gio @li @c ucb.ucp.webdav +@li @c ucb.ucp.webdav.curl @section unotools diff --git a/ucb/Library_ucpdav1.mk b/ucb/Library_ucpdav1.mk index 5d1634e67190..c4c739773d13 100644 --- a/ucb/Library_ucpdav1.mk +++ b/ucb/Library_ucpdav1.mk @@ -37,6 +37,7 @@ $(eval $(call gb_Library_use_externals,ucpdav1,\ $(eval $(call gb_Library_add_exception_objects,ucpdav1,\ ucb/source/ucp/webdav-curl/ContentProperties \ + ucb/source/ucp/webdav-curl/CurlUri \ ucb/source/ucp/webdav-curl/DAVProperties \ ucb/source/ucp/webdav-curl/DAVResourceAccess \ ucb/source/ucp/webdav-curl/DAVSessionFactory \ diff --git a/ucb/source/ucp/webdav-curl/ContentProperties.cxx b/ucb/source/ucp/webdav-curl/ContentProperties.cxx index c3d663434869..362af841c7be 100644 --- a/ucb/source/ucp/webdav-curl/ContentProperties.cxx +++ b/ucb/source/ucp/webdav-curl/ContentProperties.cxx @@ -19,7 +19,7 @@ #include <memory> #include <com/sun/star/util/DateTime.hpp> -#include "SerfUri.hxx" +#include "CurlUri.hxx" #include "DAVResource.hxx" #include "DAVProperties.hxx" #include "DateTimeHelper.hxx" @@ -83,7 +83,7 @@ ContentProperties::ContentProperties( const DAVResource& rResource ) // Title try { - SerfUri aURI( rResource.uri ); + CurlUri const aURI( rResource.uri ); m_aEscapedTitle = aURI.GetPathBaseName(); (*m_xProps)[ OUString( "Title" ) ] diff --git a/ucb/source/ucp/webdav-curl/CurlUri.cxx b/ucb/source/ucp/webdav-curl/CurlUri.cxx new file mode 100644 index 000000000000..5ab41db8d756 --- /dev/null +++ b/ucb/source/ucp/webdav-curl/CurlUri.cxx @@ -0,0 +1,285 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "CurlUri.hxx" + +#include <sal/log.hxx> +#include <rtl/uri.hxx> +#include <rtl/ustrbuf.hxx> + +#include <optional> + +namespace http_dav_ucp +{ +const auto DEFAULT_HTTP_PORT = 80; +const auto DEFAULT_HTTPS_PORT = 443; + +static ::std::optional<OUString> GetURLComponent(CURLU& rURI, CURLUPart const what, + CURLUcode const expected, + unsigned int const flags = 0) +{ + char* pPart(nullptr); + auto uc = curl_url_get(&rURI, what, &pPart, flags); + if (expected != CURLUE_OK && uc == expected) + { + return ::std::optional<OUString>(); + } + if (uc != CURLUE_OK) + { + SAL_WARN("ucb.ucp.webdav.curl", "curl_url_get failed: " << what << " " << uc); + throw DAVException(DAVException::DAV_INVALID_ARG); + } + assert(pPart); + CurlUniquePtr<char> pPart2(pPart); + return ::rtl::OStringToOUString(pPart, RTL_TEXTENCODING_UTF8); +} + +void CurlUri::Init() +{ + // looks like the result should be the same as the old calculateURI() + auto const oURI(GetURLComponent(*m_pUrl, CURLUPART_URL, CURLUE_OK, CURLU_NO_DEFAULT_PORT)); + assert(oURI); + m_URI = *oURI; + + auto const oScheme(GetURLComponent(*m_pUrl, CURLUPART_SCHEME, CURLUE_NO_SCHEME)); + if (oScheme) + { + m_Scheme = *oScheme; + } + auto const oUser(GetURLComponent(*m_pUrl, CURLUPART_USER, CURLUE_NO_USER)); + if (oUser) + { + m_User = *oUser; + } + auto const oPassWord(GetURLComponent(*m_pUrl, CURLUPART_PASSWORD, CURLUE_NO_PASSWORD)); + if (oPassWord) + { + m_Password = *oPassWord; + } + auto const oHost(GetURLComponent(*m_pUrl, CURLUPART_HOST, CURLUE_NO_HOST)); + if (oHost) + { + m_Host = *oHost; + } + // DAV schemes always have port but Content::transfer() is called with + // arbitrary URLs so use CURLUE_NO_PORT + auto const oPort(GetURLComponent(*m_pUrl, CURLUPART_PORT, CURLUE_NO_PORT, CURLU_DEFAULT_PORT)); + if (oPort) + { + m_nPort = oPort->toInt32(); + } + + auto const oPath(GetURLComponent(*m_pUrl, CURLUPART_PATH, CURLUE_OK)); + assert(oPath); + m_Path = *oPath; + + // TODO: why put this in *path* ? because before 2007, ne_uri path contained query/fragment as well :-/ + auto const oQuery(GetURLComponent(*m_pUrl, CURLUPART_QUERY, CURLUE_NO_QUERY)); + if (oQuery) + { + m_Path += *oQuery; + } + auto const oFragment(GetURLComponent(*m_pUrl, CURLUPART_FRAGMENT, CURLUE_NO_FRAGMENT)); + if (oFragment) + { + m_Path += *oFragment; + } +} + +CurlUri::CurlUri(::std::u16string_view const rURI) +{ + // note: in the old implementation, the rURI would be URI-encoded again + // here, apparently because it could actually be an IRI (RFC 3987) and + // neon didn't support that - not clear if this is a good idea + + m_pUrl.reset(curl_url()); + if (!m_pUrl) + { + throw ::std::bad_alloc(); + } + + // use curl to parse the URI, to get a consistent interpretation + OString const utf8URI(OUStringToOString(rURI, RTL_TEXTENCODING_UTF8)); + auto uc = curl_url_set(m_pUrl.get(), CURLUPART_URL, utf8URI.getStr(), 0); + if (uc != CURLUE_OK) + { + SAL_WARN("ucb.ucp.webdav.curl", "curl_url_set failed: " << uc); + throw DAVException(DAVException::DAV_INVALID_ARG); + } + + Init(); +} + +CurlUri::CurlUri(CURLU /*const*/& rUrl) + : m_pUrl(curl_url_dup(&rUrl)) +{ + if (!m_pUrl) + { + throw ::std::bad_alloc(); + } + + Init(); +} + +CurlUri::CurlUri(CurlUri const& rOther) + : m_pUrl(curl_url_dup(rOther.m_pUrl.get())) + , m_URI(rOther.m_URI) + , m_Scheme(rOther.m_Scheme) + , m_User(rOther.m_User) + , m_Password(rOther.m_Password) + , m_Host(rOther.m_Host) + , m_nPort(rOther.m_nPort) + , m_Path(rOther.m_Path) +{ + assert(rOther.m_pUrl); + if (!m_pUrl) + { + throw ::std::bad_alloc(); + } +} + +void CurlUri::operator=(CurlUri const& rOther) +{ + assert(rOther.m_pUrl); + m_pUrl.reset(curl_url_dup(rOther.m_pUrl.get())); + if (!m_pUrl) + { + throw ::std::bad_alloc(); + } + m_URI = rOther.m_URI; + m_Scheme = rOther.m_Scheme; + m_User = rOther.m_User; + m_Password = rOther.m_Password; + m_Host = rOther.m_Host; + m_nPort = rOther.m_nPort; + m_Path = rOther.m_Path; +} + +bool CurlUri::operator==(CurlUri const& rOther) const { return m_URI == rOther.m_URI; } + +OUString CurlUri::GetPathBaseName() const +{ + sal_Int32 nPos = m_Path.lastIndexOf('/'); + sal_Int32 nTrail = 0; + if (nPos == m_Path.getLength() - 1) + { + // Trailing slash found. Skip. + nTrail = 1; + nPos = m_Path.lastIndexOf('/', nPos); + } + if (nPos == -1) + { + return "/"; + } + OUString aTemp(m_Path.copy(nPos + 1, m_Path.getLength() - nPos - 1 - nTrail)); + + // query, fragment present? + nPos = aTemp.indexOf('?'); + if (nPos == -1) + nPos = aTemp.indexOf('#'); + + if (nPos != -1) + aTemp = aTemp.copy(0, nPos); + + return aTemp; +} + +OUString CurlUri::GetPathBaseNameUnescaped() const { return DecodeURI(GetPathBaseName()); } + +void CurlUri::SetScheme(::std::u16string_view const rScheme) +{ + OString const utf8URI(OUStringToOString(rScheme, RTL_TEXTENCODING_UTF8)); + auto uc = curl_url_set(m_pUrl.get(), CURLUPART_SCHEME, utf8URI.getStr(), 0); + if (uc != CURLUE_OK) + { + SAL_WARN("ucb.ucp.webdav.curl", "curl_url_set failed: " << uc); + throw DAVException(DAVException::DAV_INVALID_ARG); + } + auto const oURI(GetURLComponent(*m_pUrl, CURLUPART_URL, CURLUE_OK, CURLU_NO_DEFAULT_PORT)); + assert(oURI); + m_URI = *oURI; + auto const oScheme(GetURLComponent(*m_pUrl, CURLUPART_SCHEME, CURLUE_NO_SCHEME)); + if (oScheme) + { + m_Scheme = *oScheme; + } +} + +void CurlUri::AppendPath(::std::u16string_view const rPath) +{ + OUStringBuffer path(m_Path); + // FIXME: it is utter nonsense that m_Path contains query/fragment + if (path.lastIndexOf('/') != path.getLength() - 1) + { + path.append("/"); + } + path.append(rPath); + OString const utf8Path(OUStringToOString(path.makeStringAndClear(), RTL_TEXTENCODING_UTF8)); + auto uc = curl_url_set(m_pUrl.get(), CURLUPART_PATH, utf8Path.getStr(), 0); + if (uc != CURLUE_OK) + { + SAL_WARN("ucb.ucp.webdav.curl", "curl_url_set failed: " << uc); + throw DAVException(DAVException::DAV_INVALID_ARG); + } + auto const oURI(GetURLComponent(*m_pUrl, CURLUPART_URL, CURLUE_OK, CURLU_NO_DEFAULT_PORT)); + assert(oURI); + m_URI = *oURI; + auto const oPath(GetURLComponent(*m_pUrl, CURLUPART_PATH, CURLUE_OK)); + assert(oPath); + m_Path = *oPath; +} + +OUString EncodeSegment(OUString const& rSegment) +{ + return rtl::Uri::encode(rSegment, rtl_UriCharClassPchar, rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8); +} + +OUString DecodeURI(OUString const& rURI) +{ + return rtl::Uri::decode(rURI, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8); +} + +OUString ConnectionEndPointString(OUString const& rHostName, sal_uInt16 const nPort) +{ + OUStringBuffer aBuf; + + // Is host a numeric IPv6 address? + if ((rHostName.indexOf(':') != -1) && (rHostName[0] != '[')) + { + aBuf.append("["); + aBuf.append(rHostName); + aBuf.append("]"); + } + else + { + aBuf.append(rHostName); + } + + if ((nPort != DEFAULT_HTTP_PORT) && (nPort != DEFAULT_HTTPS_PORT)) + { + aBuf.append(":"); + aBuf.append(sal_Int32(nPort)); + } + return aBuf.makeStringAndClear(); +} + +} // namespace http_dav_ucp + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/ucb/source/ucp/webdav-curl/CurlUri.hxx b/ucb/source/ucp/webdav-curl/CurlUri.hxx new file mode 100644 index 000000000000..7418bd8a6f41 --- /dev/null +++ b/ucb/source/ucp/webdav-curl/CurlUri.hxx @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <curl/curl.h> + +#include <memory> + +#include <rtl/ustring.hxx> + +#include "DAVException.hxx" + +namespace http_dav_ucp +{ +template <auto fn> using deleter_from_fn = ::std::integral_constant<decltype(fn), fn>; +template <typename T> using CurlUniquePtr = ::std::unique_ptr<T, deleter_from_fn<curl_free>>; + +class CurlUri +{ +private: + /// native curl representation of parsed URI + ::std::unique_ptr<CURLU, deleter_from_fn<curl_url_cleanup>> m_pUrl; + /// duplicate state for quick access to some components + OUString m_URI; + OUString m_Scheme; + OUString m_User; + OUString m_Password; + OUString m_Host; + sal_uInt16 m_nPort = 0; + /// FIXME very misleading + OUString m_Path; + + void Init(); + +public: + CurlUri(CurlUri const& rUri); + CurlUri(CURLU /*const*/& rUrl); + void operator=(CurlUri const& rOther); + + /// @throws DAVException + explicit CurlUri(::std::u16string_view rURI); + + bool operator==(CurlUri const& rOther) const; + + CURLU* GetCURLU() { return m_pUrl.get(); } + OUString const& GetURI() const { return m_URI; } + OUString const& GetScheme() const { return m_Scheme; } + OUString const& GetUser() const { return m_User; } + OUString const& GetPassword() const { return m_Password; } + OUString const& GetHost() const { return m_Host; } + sal_uInt16 GetPort() const { return m_nPort; } + OUString const& GetPath() const { return m_Path; } + + OUString GetPathBaseName() const; + + OUString GetPathBaseNameUnescaped() const; + + /// @throws DAVException + void SetScheme(::std::u16string_view rScheme); + /// @throws DAVException + void AppendPath(::std::u16string_view rPath); +}; + +OUString EncodeSegment(OUString const& rSegment); +OUString DecodeURI(OUString const& rURI); +OUString ConnectionEndPointString(OUString const& rHost, sal_uInt16 nPort); + +} // namespace http_dav_ucp + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx b/ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx index 2019f198e61b..b377184d7cae 100644 --- a/ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx +++ b/ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx @@ -976,7 +976,7 @@ void DAVResourceAccess::initialize() osl::Guard< osl::Mutex > aGuard( m_aMutex ); if ( m_aPath.isEmpty() ) { - SerfUri aURI( m_aURL ); + CurlUri const aURI( m_aURL ); OUString aPath( aURI.GetPath() ); /* #134089# - Check URI */ @@ -1057,10 +1057,10 @@ bool DAVResourceAccess::detectRedirectCycle( { osl::Guard< osl::Mutex > aGuard( m_aMutex ); - SerfUri aUri( rRedirectURL ); + CurlUri const aUri( rRedirectURL ); return std::any_of(m_aRedirectURIs.begin(), m_aRedirectURIs.end(), - [&aUri](const SerfUri& rUri) { return aUri == rUri; }); + [&aUri](const CurlUri& rUri) { return aUri == rUri; }); } @@ -1069,9 +1069,9 @@ void DAVResourceAccess::resetUri() osl::Guard< osl::Mutex > aGuard( m_aMutex ); if ( ! m_aRedirectURIs.empty() ) { - std::vector< SerfUri >::const_iterator it = m_aRedirectURIs.begin(); + auto const it = m_aRedirectURIs.begin(); - SerfUri aUri( *it ); + CurlUri const aUri( *it ); m_aRedirectURIs.clear(); setURL ( aUri.GetURI() ); initialize(); diff --git a/ucb/source/ucp/webdav-curl/DAVResourceAccess.hxx b/ucb/source/ucp/webdav-curl/DAVResourceAccess.hxx index 429ac08897d3..783727f6cb84 100644 --- a/ucb/source/ucp/webdav-curl/DAVResourceAccess.hxx +++ b/ucb/source/ucp/webdav-curl/DAVResourceAccess.hxx @@ -34,7 +34,7 @@ #include "DAVSession.hxx" #include "DAVResource.hxx" #include "DAVTypes.hxx" -#include "SerfUri.hxx" +#include "CurlUri.hxx" namespace http_dav_ucp { @@ -49,7 +49,7 @@ class DAVResourceAccess rtl::Reference< DAVSession > m_xSession; rtl::Reference< DAVSessionFactory > m_xSessionFactory; css::uno::Reference< css::uno::XComponentContext > m_xContext; - std::vector< SerfUri > m_aRedirectURIs; + std::vector<CurlUri> m_aRedirectURIs; public: DAVResourceAccess() = default; diff --git a/ucb/source/ucp/webdav-curl/DAVSessionFactory.cxx b/ucb/source/ucp/webdav-curl/DAVSessionFactory.cxx index ee509f292cf5..812d64d2e273 100644 --- a/ucb/source/ucp/webdav-curl/DAVSessionFactory.cxx +++ b/ucb/source/ucp/webdav-curl/DAVSessionFactory.cxx @@ -20,7 +20,7 @@ #include <memory> #include "DAVSessionFactory.hxx" #include "SerfSession.hxx" -#include "SerfUri.hxx" +#include "CurlUri.hxx" using namespace http_dav_ucp; using namespace com::sun::star; @@ -43,7 +43,7 @@ rtl::Reference< DAVSession > DAVSessionFactory::createDAVSession( if ( aIt == m_aMap.end() ) { - SerfUri aURI( inUri ); + CurlUri const aURI( inUri ); std::unique_ptr< DAVSession > xElement( new SerfSession( this, inUri, *m_xProxyDecider ) ); @@ -67,7 +67,7 @@ rtl::Reference< DAVSession > DAVSessionFactory::createDAVSession( // If URL scheme is different from http or https we definitely // have to use a proxy and therefore can optimize the getProxy // call a little: - SerfUri aURI( inUri ); + CurlUri const aURI( inUri ); aIt->second = new SerfSession( this, inUri, *m_xProxyDecider ); aIt->second->m_aContainerIt = aIt; diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx b/ucb/source/ucp/webdav-curl/webdavcontent.cxx index 5d06a3192944..058a22646c1f 100644 --- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx +++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx @@ -77,7 +77,7 @@ #include "webdavprovider.hxx" #include "webdavresultset.hxx" #include "ContentProperties.hxx" -#include "SerfUri.hxx" +#include "CurlUri.hxx" #include "UCBDeadPropertyValue.hxx" #include "DAVException.hxx" #include "DAVProperties.hxx" @@ -210,7 +210,7 @@ Content::Content( rSessionFactory, Identifier->getContentIdentifier() ) ); - SerfUri aURI( Identifier->getContentIdentifier() ); + CurlUri const aURI( Identifier->getContentIdentifier() ); m_aEscapedTitle = aURI.GetPathBaseName(); } catch ( DAVException const & ) @@ -1250,7 +1250,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues( { osl::Guard< osl::Mutex > aGuard( m_aMutex ); - aUnescapedTitle = SerfUri::unescape( m_aEscapedTitle ); + aUnescapedTitle = DecodeURI(m_aEscapedTitle); xContext.set( m_xContext ); xIdentifier.set( m_xIdentifier ); xProvider = m_xProvider; @@ -1458,7 +1458,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues( // might trigger HTTP redirect. // Therefore, title must be updated here. - SerfUri aUri( xResAccess->getURL() ); + CurlUri const aUri( xResAccess->getURL() ); aUnescapedTitle = aUri.GetPathBaseNameUnescaped(); if ( rType == UNKNOWN ) @@ -1554,7 +1554,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues( m_xCachedProps->addProperties( *xProps ); m_xResAccess.reset( new DAVResourceAccess( *xResAccess ) ); - m_aEscapedTitle = SerfUri::escapeSegment( aUnescapedTitle ); + m_aEscapedTitle = EncodeSegment(aUnescapedTitle); } return xResultRow; @@ -1658,7 +1658,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( { try { - SerfUri aURI( xIdentifier->getContentIdentifier() ); + CurlUri const aURI(xIdentifier->getContentIdentifier()); aOldTitle = aURI.GetPathBaseNameUnescaped(); if ( aNewValue != aOldTitle ) @@ -1879,7 +1879,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( if ( aNewURL.lastIndexOf( '/' ) != ( aNewURL.getLength() - 1 ) ) aNewURL += "/"; - aNewURL += SerfUri::escapeSegment( aNewTitle ); + aNewURL += EncodeSegment(aNewTitle); uno::Reference< ucb::XContentIdentifier > xNewId = new ::ucbhelper::ContentIdentifier( aNewURL ); @@ -1887,8 +1887,8 @@ uno::Sequence< uno::Any > Content::setPropertyValues( try { - SerfUri sourceURI( xOldId->getContentIdentifier() ); - SerfUri targetURI( xNewId->getContentIdentifier() ); + CurlUri const sourceURI( xOldId->getContentIdentifier() ); + CurlUri targetURI( xNewId->getContentIdentifier() ); targetURI.SetScheme( sourceURI.GetScheme() ); xResAccess->MOVE( @@ -1942,7 +1942,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( aEvent.OldValue <<= aOldTitle; aEvent.NewValue <<= aNewTitle; - m_aEscapedTitle = SerfUri::escapeSegment( aNewTitle ); + m_aEscapedTitle = EncodeSegment(aNewTitle); aChanges.getArray()[ nChanged ] = aEvent; nChanged++; @@ -2429,7 +2429,7 @@ void Content::insert( OUString aTitle; try { - SerfUri aURI( aURL ); + CurlUri const aURI( aURL ); aTitle = aURI.GetPathBaseNameUnescaped(); } catch ( DAVException const & ) @@ -2518,8 +2518,8 @@ void Content::transfer( OUString aTargetURI; try { - SerfUri sourceURI( rArgs.SourceURL ); - SerfUri targetURI( xIdentifier->getContentIdentifier() ); + CurlUri sourceURI( rArgs.SourceURL ); + CurlUri targetURI( xIdentifier->getContentIdentifier() ); aTargetURI = targetURI.GetPathBaseNameUnescaped(); // Check source's and target's URL scheme diff --git a/ucb/source/ucp/webdav-curl/webdavdatasupplier.cxx b/ucb/source/ucp/webdav-curl/webdavdatasupplier.cxx index 75819bcd3f92..5715f9193728 100644 --- a/ucb/source/ucp/webdav-curl/webdavdatasupplier.cxx +++ b/ucb/source/ucp/webdav-curl/webdavdatasupplier.cxx @@ -30,7 +30,7 @@ #include "webdavcontent.hxx" #include "ContentProperties.hxx" #include "DAVProperties.hxx" -#include "SerfUri.hxx" +#include "CurlUri.hxx" #include <com/sun/star/ucb/IllegalIdentifierException.hpp> #include <com/sun/star/ucb/ResultSetException.hpp> #include <tools/diagnose_ex.h> @@ -365,14 +365,14 @@ bool DataSupplier::getData() { try { - SerfUri aURI( + CurlUri const aURI( m_pImpl->m_xContent->getResourceAccess().getURL() ); OUString aPath = aURI.GetPath(); if ( aPath.endsWith("/") ) aPath = aPath.copy( 0, aPath.getLength() - 1 ); - aPath = SerfUri::unescape( aPath ); + aPath = DecodeURI(aPath); bool bFoundParent = false; for ( size_t n = 0; n < resources.size(); ++n ) @@ -385,7 +385,7 @@ bool DataSupplier::getData() { try { - SerfUri aCurrURI( rRes.uri ); + CurlUri const aCurrURI( rRes.uri ); OUString aCurrPath = aCurrURI.GetPath(); if ( aCurrPath.endsWith("/") ) aCurrPath @@ -393,7 +393,7 @@ bool DataSupplier::getData() 0, aCurrPath.getLength() - 1 ); - aCurrPath = SerfUri::unescape( aCurrPath ); + aCurrPath = DecodeURI(aCurrPath); if ( aPath == aCurrPath ) { bFoundParent = true; diff --git a/ucb/source/ucp/webdav-curl/webdavprovider.hxx b/ucb/source/ucp/webdav-curl/webdavprovider.hxx index d1ed65061717..5468057f012d 100644 --- a/ucb/source/ucp/webdav-curl/webdavprovider.hxx +++ b/ucb/source/ucp/webdav-curl/webdavprovider.hxx @@ -46,8 +46,8 @@ namespace http_dav_ucp { // contents ) according to this scheme. #define VNDSUNSTARWEBDAV_URL_SCHEME "vnd.sun.star.webdav" #define VNDSUNSTARWEBDAVS_URL_SCHEME u"vnd.sun.star.webdavs" -#define HTTP_URL_SCHEME "http" -#define HTTPS_URL_SCHEME "https" +#define HTTP_URL_SCHEME u"http" +#define HTTPS_URL_SCHEME u"https" #define DAV_URL_SCHEME u"dav" #define DAVS_URL_SCHEME u"davs" #define WEBDAV_URL_SCHEME u"webdav" |