summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorGiuseppe Castagno <giuseppe.castagno@acca-esse.eu>2016-10-14 17:13:20 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2021-11-01 18:53:33 +0100
commit62069267024a35e323e8685c3808bf80d64ddb5c (patch)
treed6532ed788702b1139062777fb2375ec3910fbfb /ucb
parent3665527ea9f003830eb47ecd221a950c35caf731 (diff)
ucb: webdav-curl: tdf#102499 (9): Fix eXo Platform WebDAV on 'Save Remote File'
[ port of commit 59d6d5579528a66e55b75987d2d959968db485a8 ] Change-Id: I32c2bb8c3985ce8d8cf8cd0aeae513815ed40b6d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123502 Tested-by: Michael Stahl <michael.stahl@allotropia.de> Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/webdav-curl/DAVException.hxx5
-rw-r--r--ucb/source/ucp/webdav-curl/webdavcontent.cxx74
-rw-r--r--ucb/source/ucp/webdav-curl/webdavcontent.hxx4
3 files changed, 77 insertions, 6 deletions
diff --git a/ucb/source/ucp/webdav-curl/DAVException.hxx b/ucb/source/ucp/webdav-curl/DAVException.hxx
index c2f9f53acdd9..537b5a82fa2b 100644
--- a/ucb/source/ucp/webdav-curl/DAVException.hxx
+++ b/ucb/source/ucp/webdav-curl/DAVException.hxx
@@ -94,6 +94,11 @@ const sal_uInt16 SC_INSUFFICIENT_STORAGE = 507;
// unofficial status codes only used internally by LO
// used to cache the connection time out event
const sal_uInt16 USC_CONNECTION_TIMED_OUT = 908;
+ // name resolution failed
+const sal_uInt16 USC_LOOKUP_FAILED = 909;
+const sal_uInt16 USC_AUTH_FAILED = 910;
+const sal_uInt16 USC_AUTHPROXY_FAILED = 911;
+
class DAVException : public std::exception
diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index b2d645bc1f23..974867e78685 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -3720,7 +3720,7 @@ Content::ResourceType Content::getResourceType(
DAVOptions aDAVOptions;
{
- getResourceOptions( xEnv, aDAVOptions, rResAccess );
+ getResourceOptions( xEnv, aDAVOptions, rResAccess, networkAccessAllowed );
// at least class one is needed
if( aDAVOptions.isClass1() )
@@ -3931,7 +3931,8 @@ void Content::initOptsCacheLifeTime()
void Content::getResourceOptions(
const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv,
DAVOptions& rDAVOptions,
- const std::unique_ptr< DAVResourceAccess > & rResAccess )
+ const std::unique_ptr< DAVResourceAccess > & rResAccess,
+ bool * networkAccessAllowed )
{
OUString aRedirURL;
OUString aTargetURL = rResAccess->getURL();
@@ -3990,8 +3991,25 @@ void Content::getResourceOptions(
// used only internally, so the text doesn't really matter..
aStaticDAVOptionsCache.addDAVOptions( aDAVOptions,
m_nOptsCacheLifeNotFound );
- cancelCommandExecution( e, xEnv );
- // unreachable
+ if ( networkAccessAllowed != nullptr )
+ {
+ *networkAccessAllowed = *networkAccessAllowed
+ && shouldAccessNetworkAfterException(e);
+ }
+ }
+ break;
+ case DAVException::DAV_HTTP_LOOKUP:
+ {
+ SAL_WARN( "ucb.ucp.webdav", "OPTIONS - DAVException: DAV_HTTP_LOOKUP for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
+ aDAVOptions.setHttpResponseStatusCode( USC_LOOKUP_FAILED );
+ // used only internally, so the text doesn't really matter..
+ aStaticDAVOptionsCache.addDAVOptions( aDAVOptions,
+ m_nOptsCacheLifeNotFound );
+ if ( networkAccessAllowed != nullptr )
+ {
+ *networkAccessAllowed = *networkAccessAllowed
+ && shouldAccessNetworkAfterException(e);
+ }
}
break;
case DAVException::DAV_HTTP_AUTH:
@@ -4002,6 +4020,29 @@ void Content::getResourceOptions(
// she cancelled the credentials request.
// this is not actually an error, it means only that for current user this is a standard web,
// though possibly DAV enabled
+ aDAVOptions.setHttpResponseStatusCode( USC_AUTH_FAILED );
+ // used only internally, so the text doesn't really matter..
+ aStaticDAVOptionsCache.addDAVOptions( aDAVOptions,
+ m_nOptsCacheLifeNotFound );
+ if ( networkAccessAllowed != nullptr )
+ {
+ *networkAccessAllowed = *networkAccessAllowed
+ && shouldAccessNetworkAfterException(e);
+ }
+ }
+ break;
+ case DAVException::DAV_HTTP_AUTHPROXY:
+ {
+ SAL_WARN( "ucb.ucp.webdav", "OPTIONS - DAVException: DAV_HTTP_AUTHPROXY for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
+ aDAVOptions.setHttpResponseStatusCode( USC_AUTHPROXY_FAILED );
+ // used only internally, so the text doesn't really matter..
+ aStaticDAVOptionsCache.addDAVOptions( aDAVOptions,
+ m_nOptsCacheLifeNotFound );
+ if ( networkAccessAllowed != nullptr )
+ {
+ *networkAccessAllowed = *networkAccessAllowed
+ && shouldAccessNetworkAfterException(e);
+ }
}
break;
case DAVException::DAV_HTTP_ERROR:
@@ -4052,8 +4093,14 @@ void Content::getResourceOptions(
nLifeTime = m_nOptsCacheLifeNotImpl;
}
else
+ {
SAL_WARN( "ucb.ucp.webdav", "OPTIONS - SC_NOT_FOUND for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
-
+ if ( networkAccessAllowed != nullptr )
+ {
+ *networkAccessAllowed = *networkAccessAllowed
+ && shouldAccessNetworkAfterException(e);
+ }
+ }
aStaticDAVOptionsCache.addDAVOptions( aDAVOptions,
nLifeTime );
}
@@ -4087,6 +4134,23 @@ void Content::getResourceOptions(
}
}
}
+ else
+ {
+ // check current response status code, perhaps we need to set networkAccessAllowed
+ sal_uInt16 CachedResponseStatusCode = aDAVOptions.getHttpResponseStatusCode();
+ if ( networkAccessAllowed != nullptr &&
+ ( ( CachedResponseStatusCode == SC_NOT_FOUND ) ||
+ ( CachedResponseStatusCode == SC_GONE ) ||
+ ( CachedResponseStatusCode == USC_CONNECTION_TIMED_OUT ) ||
+ ( CachedResponseStatusCode == USC_LOOKUP_FAILED ) ||
+ ( CachedResponseStatusCode == USC_AUTH_FAILED ) ||
+ ( CachedResponseStatusCode == USC_AUTHPROXY_FAILED )
+ )
+ )
+ {
+ *networkAccessAllowed = *networkAccessAllowed && false;
+ }
+ }
rDAVOptions = aDAVOptions;
}
diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.hxx b/ucb/source/ucp/webdav-curl/webdavcontent.hxx
index 6afa65f9e479..bfc59d4646a2 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.hxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.hxx
@@ -289,13 +289,15 @@ public:
/// @throws css::uno::Exception
void getResourceOptions( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv,
DAVOptions& rDAVOptions,
- const std::unique_ptr< DAVResourceAccess > & rResAccess );
+ const std::unique_ptr< DAVResourceAccess > & rResAccess,
+ bool * networkAccessAllowed = nullptr);
static bool isResourceAvailable( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv,
const std::unique_ptr< DAVResourceAccess > & rResAccess,
DAVOptions& rDAVOptions );
static void removeCachedPropertyNames( const OUString & rURL );
+
};
}