Uh oh!
There was an error while loading. Please reload this page.
Implement webdav SEARCH - #3360
Conversation
mention-bot
commented
Feb 2, 2017
@icewind1991, thanks for your PR! By analyzing the history of the files in this pull request, we identified @MorrisJobke, @butonic and @nickvergessen to be potential reviewers. |
icewind1991
commented
Feb 8, 2017
Fixes #3253 |
MorrisJobke
left a comment
There was a problem hiding this comment.
Doesn't work:
$ curl -X SEARCH http://192.168.99.100/server/remote.php/dav -u admin:admin <?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
<s:exception>Sabre\DAV\Exception\NotImplemented</s:exception>
<s:message>There was no plugin in the system that was willing to handle this SEARCH method.</s:message>
</d:error>
@MorrisJobke you need to send a request body |
MorrisJobke
commented
Feb 15, 2017
I send it but it seems I forgot the text/xml header - let me retry then |
| /** @var Folder $folder $results */ | ||
| $results = $folder->search($query); | ||
| var_dump(array_map(function (Node $node) { |
There was a problem hiding this comment.
Leaving debug code in production saves me from having to create a debug patch in the future 😄
MorrisJobke
commented
Feb 15, 2017
If I create a folder <?xml version="1.0" encoding="utf-8"?>
<d:errorxmlns:d="DAV:"xmlns:s="http://sabredav.org/ns">
<s:exception>InvalidArgumentException</s:exception>
<s:message>Search is only supported on directories</s:message>
</d:error> |
icewind1991
commented
Feb 15, 2017
@MorrisJobke can you paste the full request you made? |
MorrisJobke
commented
Feb 15, 2017
|
MorrisJobke
commented
Feb 15, 2017
icewind1991
commented
Feb 17, 2017
@MorrisJobke the |
MorrisJobke
commented
Feb 20, 2017
Tested and works 👍 cc @marinofaggiana I tested it against your test setup and it works 😃 |
codecov-io
commented
Feb 21, 2017
Codecov Report
@@ Coverage Diff @@## master #3360 +/- ##
===========================================
+ Coverage 54.15% 54.7% +0.54% - Complexity 21023 21630 +607
===========================================
Files 1306 1316 +10 Lines 80264 82610 +2346 Branches 1250 1300 +50 ===========================================
+ Hits 43466 45190 +1724 - Misses 36798 37420 +622
Continue to review full report at Codecov.
|
For this body: <?xml version="1.0"?>
<d:searchrequestxmlns:d="DAV:"xmlns:oc="http://owncloud.org/ns">
<d:basicsearch>
<d:select>
<d:prop>
<d:displayname/>
</d:prop>
</d:select>
<d:from>
<d:scope>
<d:href>/files/admin</d:href>
<d:depth>infinity</d:depth>
</d:scope>
</d:from>
<d:where>
<d:like>
<d:prop>
<d:displayname/>
</d:prop>
<d:literal>Documents</d:literal>
</d:like>
</d:where>
</d:basicsearch>
</d:searchrequest>I get following response: <?xml version="1.0" encoding="utf-8"?>
<d:errorxmlns:d="DAV:"xmlns:s="http://sabredav.org/ns">
<s:exception>Sabre\DAV\Exception\ServiceUnavailable</s:exception>
<s:message>TypeError: Argument 4 passed to OC\Files\Search\SearchQuery::__construct() must be of the type array, null given, called in /var/www/nextcloud/apps/dav/lib/Files/FileSearchBackend.php on line 177</s:message>
</d:error> |
General note: Can we avoid leaking exception messages via DAV? They can sometimes contain sensitive content :) |
icewind1991
commented
Feb 22, 2017
@MorrisJobke can you retry with the updated 3rdparty |
MorrisJobke
commented
Feb 24, 2017
I now get: HTTP/1.1 207 Multi-Status
<?xml version="1.0"?>
<d:multistatusxmlns:d="DAV:"xmlns:s="http://sabredav.org/ns"xmlns:cal="urn:ietf:params:xml:ns:caldav"xmlns:cs="http://calendarserver.org/ns/"xmlns:card="urn:ietf:params:xml:ns:carddav"xmlns:oc="http://owncloud.org/ns"xmlns:nc="http://nextcloud.org/ns"/>😕 |
icewind1991
commented
Feb 24, 2017
@MorrisJobke what is the request you're trying? |
MorrisJobke
commented
Feb 28, 2017
|
mario
commented
Feb 28, 2017
@icewind1991 when doing OPTIONS, search doesn't seem to be among supported methods? |
icewind1991
commented
Feb 28, 2017
Works for me: |
mario
commented
Feb 28, 2017
via email
Ok will check once again. …On Tue, 28 Feb 2017 at 13:18, Robin Appelman ***@***.***> wrote:
Works for me:
curl -I -X OPTIONS -u test:test https://localcloud.icewind.me/remote.php/dav
...
Allow: OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT, SEARCH
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3360 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAWsubNeTyFPZjT7PiHSMFwDzucPUUKks5rhBCYgaJpZM4L1ZwO>
.
|
mario
commented
Feb 28, 2017
@icewind1991 would something like this work with your implementation, since it doesn't look like the current libs supports that draft entirely: <d:searchrequest xmlns:d="DAV:" dcr:="http://www.day.com/jcr/webdav/1.0" > cc @AndyScherzinger@tobiasKaminsky Otherwise we might look into how we can either extend it use or use (possibly?) another lib just for this particular use case if such a thing exists. |
Signed-off-by: Robin Appelman <robin@icewind.nl>
marinofaggiana
commented
Mar 4, 2017
Is changed API ??? i have a response error with my driver ... |
marinofaggiana
commented
Mar 6, 2017
ping @icewind1991 |
icewind1991
commented
Mar 6, 2017
@marinofaggiana please describe the error you're getting instead of having us guess |
marinofaggiana
commented
Mar 6, 2017
curl -u admin:XXXXXXXX -X SEARCH https://ios-demo.weasel.rocks/remote.php/dav -H "content-Type: text/xml" --data '<d:searchrequest xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns"><d:basicsearch><d:select><d:prop>oc:fileid/<d:getcontenttype/><d:getetag/>oc:size/oc:favorite/</d:prop></d:select><d:from><d:scope><d:href>/files/admin</d:href><d:depth>infinity</d:depth></d:scope></d:from><d:where><d:like><d:prop><d:displayname/></d:prop><d:literal>Nextcloud%</d:literal></d:like></d:where><d:orderby/></d:basicsearch></d:searchrequest>' |
marinofaggiana
commented
Mar 6, 2017
@icewind1991 this is the response : <d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns"> |
marinofaggiana
commented
Mar 7, 2017
@icewind1991@MorrisJobke please info for this issue. |
mario
commented
Mar 7, 2017
So search basically works, so please +1 all of you. After that, I just need it extended to support oc:favorite in a query because filter-files won't work for Android atm. |
@mario |
mario
commented
Mar 7, 2017
@marinofaggiana using that our Android lib doesn't want to parse the propstat so I don't get the properties back. |
marinofaggiana
commented
Mar 7, 2017
Modify the lib ? |
mario
commented
Mar 7, 2017
Not something I feel comfortable doing under these kind of deadlines. |
MorrisJobke
commented
Mar 8, 2017
Sorry - I screwed up the instance. It should work now. :( @marinofaggiana@icewind1991 |
@mario good work. I have been playing around with WebDAV SEARCH on nextcloud 12.0.4 and integrate it in Zimbra Nextcloud Client (https://github.com/Zimbra-Community/owncloud-zimlet) Mostly I can make it work, but I have issues searching for files with more than 2 search words. So here only the first 2 words are matched, the 3rd is ignored... is there a limit of 2 in AND? |
ghost
commented
Jan 15, 2018
https://www.ietf.org/rfc/rfc5323.txt The DAV:and operator performs a logical AND operation on the Can anyone help me to do a WebDAV Search to nextcloud with more than 2 words to look for in displayname, I think the XML example, is according to the spec, but maybe I misread. |
icewind1991
commented
Jan 15, 2018
How I understood the spec (and implemented it) is that DAV:and and DAV:or only take 2 arguments, |
ghost
commented
Jan 15, 2018
@icewind1991 thanks, that makes it a bit harder to implement on the client side. It would be nice if the rfc said |
ghost
commented
Jan 15, 2018
@icewind1991 I am thinking about asking julian reschke (his name is on the rfc) and see what he says. But should the server return a 501 Not Implemented error if I do something that is outside the webdav spec? Aka an AND with 3 criteria = 501. Now it parses only the first 2. |
reschke
commented
Jan 15, 2018
I agree that RFC 5323 could be clearer, but AFAIR, we would have said "two" if we had intended to restrict it to two operands. |
icewind1991
commented
Jan 15, 2018
I will see if I can extend the implementation to allow for arbitrary number of arguments |
ghost
commented
Jan 16, 2018
via email
@icewind1991 thanks! |
rullzer
commented
Jan 16, 2018
I just noticed this as well. Since and is associative you can just do
and transform it into
|
icewind1991
commented
Jan 16, 2018
Fix is here |
rullzer
commented
Feb 25, 2018
@pinkylabs please open a new issue. |

Still WIP, but submitting so the clients can start with it, functionality wise it should be ready for clients to start using the API
requires add icewind/searchdav 3rdparty#34
needs proper test coverage
Adds a mechanism to describe more complex search queries
Extend the cache to support doing these searches
Expose the new search mechanism in
\OCP\Files\FolderImplement rfc5323 SEARCH to expose this to the world
fixesSearch API #676
Clients can do a search by firing a SEARCH request at
nextcloud/remote.php/davwith a search body as described by the rfcFor an example of a somewhat complex query that is possible with this api see this example request
cc @mario