ucb/source/ucp/webdav-curl/DAVException.hxx  |    5 +
 ucb/source/ucp/webdav-curl/webdavcontent.cxx |   74 +++++++++++++++++++++++++--
 ucb/source/ucp/webdav-curl/webdavcontent.hxx |    4 +
 3 files changed, 77 insertions(+), 6 deletions(-)

New commits:
commit 62069267024a35e323e8685c3808bf80d64ddb5c
Author:     Giuseppe Castagno <giuseppe.casta...@acca-esse.eu>
AuthorDate: Fri Oct 14 17:13:20 2016 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Mon Nov 1 18:53:33 2021 +0100

    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.st...@allotropia.de>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

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 );
+
 };
 
 }

Reply via email to