-
Notifications
You must be signed in to change notification settings - Fork 2.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
Verify that a file exists before we share it #7780
Conversation
I think patching it here is the wrong approach as there may be other apps which are using this function wrong. We should - at least in master - do this check within ( Line 475 in b2757e6
|
You're right, that's a better approach |
@icewind will Filesystem::getPath () return false for files the user has no access to - or only for invalid file ids? |
It will return false if the id is not found within any of the storages the user has access to. @LukasReschke updated |
@icewind1991 unit test? 😉 |
💣 Test Failed. 💣 |
It works 👍 (I've tested before and after the fix with curl) |
Failing unit tests are related to resharing, adding support for "regular" resharing is easy but I dont know how to add support for resharing a file from a shared folder. |
Hmm, I forgot to test resharing... trying out now. |
Manual test also fails for reshare. |
Another idea would be that if the check fails, find out whether the current user has access to that file. There should be another entry in the sharing table where "share_with = 'current_user' AND item_source = ? and share_type = ?". Not sure how to use that convoluted internal API to request this. Maybe looking at how the OCS Share API does it might help. |
I already got that far, it's a simple one line addition. The problem is files from shared folders, if the folder |
If I remember well there might be a way (in the OCS Share API) to detect if a file in a subfolder is shared / what share it belongs to. |
Just tried it, and it doesn't work. It looks like it's not possible to use the OCS Share API to get a share id when being the receiver of the share. In the example above, I tried calling @purigarcia can you confirm that the above is correct ? |
@icewind1991 Just found this method: |
@PVince81 unfortunately that requires knowing the owner of the file and the path |
@PVince81 the result of the OCS call is correct. You should only get the share ID for files you shared. I think the problem we try to fix here doesn't exists for the ocs api because the ocs api works with the path instead of the file id and if you try to a share a path which doesn't exists you will get an error. @icewind1991 Is there no way to get the owner and the owners path for a file if we know the file id? If this really isn't possible than I think we need to solve the problem at a higher level. In this case the ajax call should contain the path to the file for the current user, similar to the ocs api. This way we can easily do all the checks we want. The only problem, it looks like the methods for the ajax calls are generic ones which get also called for other shares. |
Passing the path in the ajax call seems like the best solution, then the check becomes a simple |
Any update here ? |
Waiting for #7935 |
rebased and squashed. @PVince81 please retest (also with reshares) |
🚀 Test Passed. 🚀 |
Tests:
|
👍 |
@icewind1991 can you add a unit test for this case ? |
@PVince81 done |
🚀 Test Passed. 🚀 |
The inspection completed: 1 new issues, 3 updated code elements |
@icewind1991 awesome! @schiesbn can you please review this ? |
@schiesbn @DeepDiver1975 can you have a look at this |
looks good to me! 👍 |
Verify that a file exists before we share it
This needs a backport. #7935 has been already backported. What do you think @karlitschek? @icewind1991 Can you take care of this? |
yes. agreed. Backport please |
Prevents invalid entries from getting into the share table and folder
cc @karlitschek @DeepDiver1975 @LukasReschke