summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/api
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2015-08-29 13:31:18 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2015-08-30 10:31:43 +0200
commit2aff11c80bbc7fb0524c52d17824d68bda43aac5 (patch)
treec0c82538bdbdf9fc38f983831c091ba707ba2e58 /apps/files_sharing/api
parentfc64ea670d63b125d277ddcacc0b48253b62c28d (diff)
downloadnextcloud-server-2aff11c80bbc7fb0524c52d17824d68bda43aac5.tar.gz
nextcloud-server-2aff11c80bbc7fb0524c52d17824d68bda43aac5.zip
Actually validate the expire date on share
* Added more intergration tests
Diffstat (limited to 'apps/files_sharing/api')
-rw-r--r--apps/files_sharing/api/local.php12
1 files changed, 8 insertions, 4 deletions
diff --git a/apps/files_sharing/api/local.php b/apps/files_sharing/api/local.php
index eeb31899830..87025998b3d 100644
--- a/apps/files_sharing/api/local.php
+++ b/apps/files_sharing/api/local.php
@@ -292,7 +292,7 @@ class Local {
try {
$expirationDate = isset($_POST['expireDate']) ? self::parseDate($_POST['expireDate']) : null;
} catch (\Exception $e) {
- return new \OC_OCS_Result(null, 404, 'Invalid Date');
+ return new \OC_OCS_Result(null, 404, 'Invalid Date. Format must be YYYY-MM-DD.');
}
break;
@@ -315,7 +315,11 @@ class Local {
$expirationDate
);
} catch (HintException $e) {
- return new \OC_OCS_Result(null, 400, $e->getHint());
+ if ($e->getCode() === 0) {
+ return new \OC_OCS_Result(null, 400, $e->getHint());
+ } else {
+ return new \OC_OCS_Result(null, $e->getCode(), $e->getHint());
+ }
} catch (\Exception $e) {
return new \OC_OCS_Result(null, 403, $e->getMessage());
}
@@ -559,13 +563,13 @@ class Local {
*/
private static function parseDate($expireDate) {
if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $expireDate) === 0) {
- throw new \Exception();
+ throw new \Exception('Invalid date. Format must be YYYY-MM-DD');
}
$date = new \DateTime($expireDate);
if ($date === false) {
- throw new \Exception();
+ throw new \Exception('Invalid date. Format must be YYYY-MM-DD');
}
return $date;