Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/ExpireShare.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ private function getShareById($id) {
}

public function expireShare(array $param) {
if (!\array_key_exists('share_id', $param)) {
return new Result(null, 400, 'Share Id not provided');
}
$id = \trim($param["share_id"]);
if (!$this->shareManager->shareApiEnabled()) {
return new Result(null, 404, 'Share API is disabled');
Expand Down
6 changes: 6 additions & 0 deletions lib/LastLoginDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public function __construct(
* @return Result
*/
public function setLastLoginDate($param) {
if (!\array_key_exists('user', $param)) {
return new Result(null, 400, 'User id not provided');
}
$user = \trim($param['user']);
try {
$account = $this->accountMapper->getByUid($user);
Expand Down Expand Up @@ -88,6 +91,9 @@ public function setLastLoginDate($param) {
* @return Result
*/
public function getLastLoginDate($param) {
if (!\array_key_exists('user', $param)) {
return new Result(null, 400, 'User id not provided');
}
$user = \trim($param['user']);
try {
$account = $this->accountMapper->getByUid($user);
Expand Down
37 changes: 26 additions & 11 deletions lib/ServerFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ public function __construct(IRequest $request) {
* @return Result
*/
public function mkDir() {
$dir = \trim($this->request->getParam('dir'), '/');
$dir = \trim($this->request->getParam('dir', ''), '/');
if ($dir === "") {
return new Result(null, 400, "cannot create dir, dir not specified");
}
$targetDir = \OC::$SERVERROOT . "/$dir";
if (!\file_exists($targetDir)) {
// Ask for the full mode, it will be masked by the current umask anyway
Expand All @@ -79,7 +82,7 @@ public function mkDir() {
* @return Result
*/
public function rmDir() {
$dir = \trim($this->request->getParam('dir'), '/');
$dir = \trim($this->request->getParam('dir', ''), '/');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes to the call to getParam add a default value of the empty string.
That ensures that the empty string will be passed to trim if the Param does not exist.

if ($dir === "") {
return new Result(null, 400, "cannot delete dir, no dir name given");
}
Expand Down Expand Up @@ -139,8 +142,11 @@ public function rmDir() {
* @return Result
*/
public function readFile() {
$filePath = \trim($this->request->getParam('file'), '/');
$isAbsolutePath = \trim($this->request->getParam('absolute'));
$filePath = \trim($this->request->getParam('file', ''), '/');
if ($filePath === "") {
return new Result(null, 400, "cannot read file, file path not specified");
}
$isAbsolutePath = \trim($this->request->getParam('absolute', ''));
if ($isAbsolutePath === 'true') {
$targetFile = "/$filePath";
} else {
Expand All @@ -166,7 +172,10 @@ public function readFile() {
* @return Result
*/
public function createFile() {
$filePath = \trim($this->request->getParam('file'), '/');
$filePath = \trim($this->request->getParam('file', ''), '/');
if ($filePath === '') {
return new Result(null, 400, "cannot create file, file path not specified");
}
$content = $this->request->getParam('content');
$targetFile = \OC::$SERVERROOT . "/$filePath";
$result = \file_put_contents($targetFile, $content);
Expand All @@ -185,7 +194,7 @@ public function createFile() {
* @return Result
*/
public function deleteFile() {
$filePath = \trim($this->request->getParam('file'), '/');
$filePath = \trim($this->request->getParam('file', ''), '/');
if ($filePath === "") {
return new Result(null, 400, "cannot delete file, no file name given");
}
Expand Down Expand Up @@ -214,7 +223,7 @@ public function deleteFile() {
*/
public function listFiles() {
$result = [];
$dir = \trim($this->request->getParam('dir'), '/');
$dir = \trim($this->request->getParam('dir', ''), '/');
if ($dir === "") {
return new Result(null, 400, "cannot list files in dir, no dir name given");
}
Expand Down Expand Up @@ -248,16 +257,22 @@ public function listFiles() {
* @return Result
*/
public function moveFile() {
$filePath = \trim($this->request->getParam('source'), '/');
$isAbsolutePath = \trim($this->request->getParam('absolute'));
$filePath = \trim($this->request->getParam('source', ''), '/');
if ($filePath === "") {
return new Result(null, 400, "cannot move file, file path not specified");
}
$isAbsolutePath = \trim($this->request->getParam('absolute', ''));
if ($isAbsolutePath === 'true') {
$filePath = "/$filePath";
} else {
$filePath = \OC::$SERVERROOT . "/$filePath";
}

$fileTarget = \trim($this->request->getParam('target'), '/');
$isAbsolutePath = \trim($this->request->getParam('absolute'));
$fileTarget = \trim($this->request->getParam('target', ''), '/');
if ($fileTarget === "") {
return new Result(null, 400, "cannot move file, file target not specified");
}
$isAbsolutePath = \trim($this->request->getParam('absolute', ''));
if ($isAbsolutePath === 'true') {
$fileTarget = "/$fileTarget";
} else {
Expand Down
5 changes: 4 additions & 1 deletion lib/TestingSkeletonDirectory.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ public function get() {
* @return Result
*/
public function set() {
$directory = \trim($this->request->getParam('directory'), '/');
$directory = \trim($this->request->getParam('directory', ''), '/');
if ($directory === '') {
return new Result(null, 400, "cannot set skeleton directory, dir not specified");
}
$folder = Filesystem::normalizePath($directory, true);
if (Filesystem::isValidPath($folder) === false) {
return new Result(null, 400, "invalid folder name");
Expand Down