Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-03-05 16:12:58 +0400
committerJoas Schilling <nickvergessen@gmx.de>2014-03-05 16:12:58 +0400
commit80393d9c0ff44c0614960cc6b7b7d8cc5bd17743 (patch)
tree874bc3d9449c8036fcc4f6d93697f800cfddc03a /core
parent7edd8df07f50b0a556889b276eaeeab37cb175be (diff)
Do not allow setting an expiration date in the past
Fix #7297
Diffstat (limited to 'core')
-rw-r--r--core/ajax/share.php8
-rw-r--r--core/js/share.js6
2 files changed, 13 insertions, 1 deletions
diff --git a/core/ajax/share.php b/core/ajax/share.php
index 86ee018e388..abcb4b5c22b 100644
--- a/core/ajax/share.php
+++ b/core/ajax/share.php
@@ -80,6 +80,14 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
break;
case 'setExpirationDate':
if (isset($_POST['date'])) {
+ $l = OC_L10N::get('core');
+ $date = new \DateTime($_POST['date']);
+ $today = new \DateTime('now');
+
+ if ($date < $today) {
+ OC_JSON::error(array('data' => array('message' => $l->t('Expiration date is in the past.'))));
+ return;
+ }
$return = OCP\Share::setExpirationDate($_POST['itemType'], $_POST['itemSource'], $_POST['date']);
($return) ? OC_JSON::success() : OC_JSON::error();
}
diff --git a/core/js/share.js b/core/js/share.js
index 0939259b7da..0b65e153093 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -720,7 +720,11 @@ $(document).ready(function() {
var itemSource = $('#dropdown').data('item-source');
$.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'setExpirationDate', itemType: itemType, itemSource: itemSource, date: $(this).val() }, function(result) {
if (!result || result.status !== 'success') {
- OC.dialogs.alert(t('core', 'Error setting expiration date'), t('core', 'Error'));
+ if (!result.data.message) {
+ OC.dialogs.alert(t('core', 'Error setting expiration date'), t('core', 'Error'));
+ } else {
+ OC.dialogs.alert(result.data.message, t('core', 'Error'));
+ }
}
});
});