ucb/source/ucp/webdav-curl/webdavcontent.cxx |   36 +++++++++++++++------------
 1 file changed, 20 insertions(+), 16 deletions(-)

New commits:
commit fa54bca695f6d17e871e43db75f06a63aec7b739
Author:     Michael Stahl <[email protected]>
AuthorDate: Mon Nov 22 16:43:32 2021 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Tue Nov 23 12:07:35 2021 +0100

    tdf#145769 ucb: webdav-curl: stop returning IsDocument=true if it doesn't 
exist
    
    Content::getPropertyValues() has no less than 2 fallbacks that cause it
    to return property values IsDocument=true and IsFolder=false in case
    there is an authentication failure or server connection failure.
    
    Change-Id: Iddcda6420c517f522d98e58b12a7e19247ff2d1b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125667
    Tested-by: Michael Stahl <[email protected]>
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx 
b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index eb19e0265659..f74bf01b5125 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -1339,13 +1339,14 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
         }
     }
 
+    bool bNetworkAccessAllowed = true;
+
     if ( !m_bTransient && !bHasAll )
     {
         // Obtain values from server...
 
 
         // First, identify whether resource is DAV or not
-        bool bNetworkAccessAllowed = true;
         const ResourceType eType = getResourceType(
                 xEnv, xResAccess, &bNetworkAccessAllowed );
 
@@ -1573,7 +1574,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
         // For DAV resources we only know the Title, for non-DAV
         // resources we additionally know that it is a document.
 
-        if ( eType == DAV )
+        else if ( eType == DAV )
         {
             if (!xProps)
                 xProps.reset(new ContentProperties(aUnescapedTitle));
@@ -1634,21 +1635,24 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
                     uno::makeAny( aDate ),
                     true );
             }
-            // If WebDAV didn't return the resource type, assume default
-            // This happens e.g. for lists exported by SharePoint
-            else if ( (*it) == "IsFolder" )
-            {
-                xProps->addProperty(
-                    (*it),
-                    uno::makeAny( false ),
-                    true );
-            }
-            else if ( (*it) == "IsDocument" )
+            else if (bNetworkAccessAllowed) // don't set these if connection 
failed
             {
-                xProps->addProperty(
-                    (*it),
-                    uno::makeAny( true ),
-                    true );
+                // If WebDAV didn't return the resource type, assume default
+                // This happens e.g. for lists exported by SharePoint
+                if ((*it) == "IsFolder")
+                {
+                    xProps->addProperty(
+                        (*it),
+                        uno::makeAny( false ),
+                        true );
+                }
+                else if ((*it) == "IsDocument")
+                {
+                    xProps->addProperty(
+                        (*it),
+                        uno::makeAny( true ),
+                        true );
+                }
             }
         }
     }

Reply via email to