-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement webdav SEARCH #3360
Implement webdav SEARCH #3360
Conversation
@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. |
Fixes #3253 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
|
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected? 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving debug code in production saves me from having to create a debug patch in the future 😄
a7535fc
to
2d4cb4d
Compare
If I create a folder <?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>Search is only supported on directories</s:message>
</d:error> |
@MorrisJobke can you paste the full request you made? |
|
@MorrisJobke the |
Tested and works 👍 cc @marinofaggiana I tested it against your test setup and it works 😃 |
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:searchrequest xmlns: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:error xmlns: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 :) |
@MorrisJobke can you retry with the updated 3rdparty |
I now get: HTTP/1.1 207 Multi-Status
<?xml version="1.0"?>
<d:multistatus xmlns: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"/> 😕 |
@MorrisJobke what is the request you're trying? |
|
@icewind1991 when doing OPTIONS, search doesn't seem to be among supported methods? |
Works for me:
|
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>
.
|
@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>
caab1f9
to
56f84d6
Compare
ping @icewind1991 |
@marinofaggiana please describe the error you're getting instead of having us guess |
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>' |
@icewind1991 this is the response : <d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns"> |
@icewind1991 @MorrisJobke please info for this issue. |
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 |
@marinofaggiana using that our Android lib doesn't want to parse the propstat so I don't get the properties back. |
Modify the lib ? |
Not something I feel comfortable doing under these kind of deadlines. |
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?
|
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.
|
How I understood the spec (and implemented it) is that DAV:and and DAV:or only take 2 arguments, |
@icewind1991 thanks, that makes it a bit harder to implement on the client side. It would be nice if the rfc said |
@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. |
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. |
I will see if I can extend the implementation to allow for arbitrary number of arguments |
@icewind1991 thanks!
|
I just noticed this as well. Since and is associative you can just do
and transform it into
|
Fix is here |
@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\Folder
Implement rfc5323 SEARCH to expose this to the world
fixes Search API #676
Clients can do a search by firing a SEARCH request at
nextcloud/remote.php/dav
with 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