Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 5.1k
[stable30] fix(dav): file drop nickname#53279
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -8,6 +8,7 @@ | ||
| use OC\Files\View; | ||
| use OCP\Share\IShare; | ||
| use Sabre\DAV\Exception\BadRequest; | ||
| use Sabre\DAV\Exception\MethodNotAllowed; | ||
| use Sabre\DAV\ServerPlugin; | ||
| use Sabre\HTTP\RequestInterface; | ||
| @@ -65,14 +66,28 @@ public function beforeMethod(RequestInterface $request, ResponseInterface $respo | ||
| // Extract the attributes for the file request | ||
| $isFileRequest = false; | ||
| $attributes = $this->share->getAttributes(); | ||
| $nickName = $request->hasHeader('X-NC-Nickname') ? urldecode($request->getHeader('X-NC-Nickname')) : null; | ||
| $nickName = $request->hasHeader('X-NC-Nickname') ? trim(urldecode($request->getHeader('X-NC-Nickname'))) : null; | ||
| if ($attributes !== null) { | ||
| $isFileRequest = $attributes->getAttribute('fileRequest', 'enabled') === true; | ||
| } | ||
| // We need a valid nickname for file requests | ||
| if ($isFileRequest && ($nickName == null || trim($nickName) === '')) { | ||
| throw new MethodNotAllowed('Nickname is required for file requests'); | ||
| if ($isFileRequest && !$nickName) { | ||
Uh oh!There was an error while loading. Please reload this page. Check noticeCode scanning / Psalm RiskyTruthyFalsyComparison
Operand of type null|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead.
| ||
| throw new BadRequest('Nickname is required for file requests'); | ||
| } | ||
| if ($nickName !== null) { | ||
| try { | ||
| $this->view->verifyPath($path, $nickName); | ||
| } catch (\Exception $e) { | ||
| // If the path is not valid, we throw an exception | ||
| throw new BadRequest('Invalid nickname: ' . $nickName); | ||
| } | ||
| // Forbid nicknames starting with a dot | ||
| if (str_starts_with($nickName, '.')) { | ||
| throw new BadRequest('Invalid nickname: ' . $nickName); | ||
| } | ||
| } | ||
| // If this is a file request we need to create a folder for the user | ||
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 2142-2142.js.license |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Check notice
Code scanning / Psalm
PossiblyNullArgument