Problems with SEARCH-method via WebDAV

Hello,
I have two problems with the SEARCH method via WebDAV. I can search for mime types “text/%” like in the example (https://docs.nextcloud.com/server/15/developer_manual/client_apis/WebDAV/search.html), but not for e.g. “text/xml” or “image/png”. Furthermore it seems that the <d:depth> tag is ignored (https://tools.ietf.org/html/rfc5323#page-22).

Example where ‘d:depth’ is ignored:

dirk@schleppi:~/develop/fritz/test> curl -s -u dirk:jeheim -k --noproxy '*' -H "content-Type: text/xml" -X SEARCH  --data '@requests/search-test.xml'  'https://balu/nextcloud/remote.php/dav/' | xmllint --format - | head -25
<?xml version="1.0"?>
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">
  <d:response>
    <d:href>/nextcloud/remote.php/dav/files/dirk/Photos/14-06-08%2020-16-22%201652.jpg</d:href>
    <d:propstat>
      <d:prop>
        <oc:fileid>735</oc:fileid>
        <d:getcontenttype>image/jpeg</d:getcontenttype>
        <d:getetag>"8b6b79a4a8a257b85396e0b1c009aed7"</d:getetag>
        <oc:size>2784601</oc:size>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
    <d:propstat>
      <d:prop>
        <d:displayname/>
      </d:prop>
      <d:status>HTTP/1.1 404 Not Found</d:status>
    </d:propstat>
  </d:response>
  <d:response>
    <d:href>/nextcloud/remote.php/dav/files/dirk/SofortUpload/Camera/IMG_20180707_173251.jpg</d:href>
    <d:propstat>
      <d:prop>
        <oc:fileid>49220</oc:fileid>

you can see that files are also listed in subdirectories. There is no difference between depth=0, 1 or infinity


Here is the corresponding XML request with d:depth = 0 and image/%:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Achtung: beispiel von nextclod-developer ist falsch. url muss sein .../remote.php/dav/
     relativen pfad dann nach d:scope unten...
     Header: Content-Type muss text/xml oder application/xml sein. Sonst keine 
     SEARCH-methode vorhanden -->

 <d:searchrequest xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
     <d:basicsearch>
         <d:select>
             <d:prop>
                 <oc:fileid/>
                 <d:displayname/>
                 <d:getcontenttype/>
                 <d:getetag/>
                 <oc:size/>
             </d:prop>
         </d:select>
         <d:from>
             <d:scope>
                 <d:href>/files/dirk/</d:href>
                 <!-- <d:depth>infinity</d:depth> -->
                 <d:depth>0</d:depth>
             </d:scope>
         </d:from>
         <d:where>
             <d:like>
                 <d:prop>
                     <d:getcontenttype/>
                 </d:prop>
                 <!-- <d:literal>text/%</d:literal> -->
                 <d:literal>image/%</d:literal>
             </d:like>
         </d:where>
         <d:orderby/>
    </d:basicsearch>
</d:searchrequest>

If I change image/% to image/png in the above request I get the following error:

dirk@schleppi:~/develop/fritz/test> curl -s -u dirk:jeheim -k --noproxy '*' -H "content-Type: text/xml" -X SEARCH  --data '@requests/search-test.xml'  'https://balu/nextcloud/remote.php/dav/' | xmllint --format - | head -10
<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
  <s:exception>Doctrine\DBAL\Exception\DriverException</s:exception>
  <s:message>An exception occurred while executing 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`, `encrypted`, `etag`, `permissions`, `checksum` FROM `oc_filecache` `file` WHERE (`storage` = ?) AND (`mimetype`  COLLATE utf8mb4_general_ci LIKE ?)' with params [2, "image\/png"]:

SQLSTATE[42000]: Syntax error or access violation: 1253 COLLATION 'utf8mb4_general_ci' is not valid for CHARACTER SET 'latin1'</s:message>
</d:error>

And if I use ‘image/png%’ completely senseless I get this pretty error: “Unsupported query value for mimetype: image/png%, only values in the format “mime/type” or “mime/%” are supported”.

curl -s -u dirk:jeheim -k --noproxy '*' -H "content-Type: text/xml" -X SEARCH  --data '@requests/search-test.xml'  'https://balu/nextcloud/remote.php/dav/' | xmllint --format - | head -10
<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
  <s:exception>InvalidArgumentException</s:exception>
  <s:message>Unsupported query value for mimetype: image/png%, only values in the format "mime/type" or "mime/%" are supported</s:message>
</d:error>

I am using openSuse 15.0 with nextcloud 15.0.0-lp150.56.1 from this extra-repo ‘http://ftp.gwdg.de/pub/opensuse/repositories/server:/php:/applications/openSUSE_Leap_15.0/’ and MariaDB.

any ideas?

cu

Did you ever figure this out? I’m at NC 18.0.x and cannot get searches to work either (getting “Internal error”, no matter what I try).