-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add Webdav-Location header in private link redirect #30383
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,7 @@ | |
| use OCP\IURLGenerator; | ||
| use OCP\IUserSession; | ||
| use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||
| use OCP\AppFramework\Http; | ||
|
|
||
| /** | ||
| * Class ViewController | ||
|
|
@@ -282,12 +283,14 @@ public function showFile($fileId) { | |
| $files = $baseFolder->getById($fileId); | ||
| $params = []; | ||
|
|
||
| $isFilesView = true; | ||
| if (empty($files) && $this->appManager->isEnabledForUser('files_trashbin')) { | ||
| // Access files_trashbin if it exists | ||
| if ( $this->rootFolder->nodeExists($uid . '/files_trashbin/files/')) { | ||
| $baseFolder = $this->rootFolder->get($uid . '/files_trashbin/files/'); | ||
| $files = $baseFolder->getById($fileId); | ||
| $params['view'] = 'trashbin'; | ||
| $isFilesView = false; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -302,14 +305,23 @@ public function showFile($fileId) { | |
| // and scroll to the entry | ||
| $params['scrollto'] = $file->getName(); | ||
| } | ||
| return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', $params)); | ||
| $response = new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', $params)); | ||
| if ($isFilesView) { | ||
| $webdavUrl = $this->urlGenerator->linkTo('', 'remote.php') . '/dav/files/' . $uid . '/'; | ||
| $webdavUrl .= ltrim($baseFolder->getRelativePath($file->getPath()), '/'); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @PVince81 take into account that the file name at this point is not URL-encoded: a file called Clients will query a non-existent file then. We should add a test for it as well.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right, I'll then add some encoding in a subsequent PR
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here we go, please have a look: #30503 |
||
| $response->addHeader('Webdav-Location', $webdavUrl); | ||
| } | ||
| return $response; | ||
| } | ||
|
|
||
| if ( $this->userSession->isLoggedIn() and empty($files)) { | ||
| if ($this->userSession->isLoggedIn() and empty($files)) { | ||
| $param["error"] = $this->l10n->t("You don't have permissions to access this file/folder - Please contact the owner to share it with you."); | ||
| return new TemplateResponse("core", 'error', ["errors" => [$param]], 'guest'); | ||
| $response = new TemplateResponse("core", 'error', ["errors" => [$param]], 'guest'); | ||
| $response->setStatus(Http::STATUS_NOT_FOUND); | ||
| return $response; | ||
| } | ||
|
|
||
| // FIXME: potentially dead code as the user is normally always logged in non-public routes | ||
| throw new \OCP\Files\NotFoundException(); | ||
| } | ||
| } | ||
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.
@PVince81 shouldn't this be endpoint-aware instead of hardcoded? i.e. using the same endpoint as the request that originated this
$response? My endpoint-juggling context might be playing mind tricks on me, though.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.
endpoint-aware in what way ?
The ViewController is not part of Webdav but it's the web page from "index.php/apps/files" so what decision do you think should be made based on this ?
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.
You're right. I was thinking on a different (non-existent) workflow.
What I really meant was If there won't be a problem to use a hardcoded WebDAV path regardless of what the client that is accessing the private link normally uses/understands.
e.g. since this request came from the iOS team and they talk with the old endpoint, the new might offer different properties, no? Or if, like in the past; we detect some problems with the endpoint on the webUI that forces us to temporarily switch back to old, etc.