diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2015-10-22 23:13:28 +0200 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2015-10-23 09:24:03 +0200 |
commit | 9071e756a103319c6747974292463f30b89ab4e3 (patch) | |
tree | b9739ecd154f92b9ce863a4688c9d40241c649ce /core/ajax | |
parent | 4f5ff9c105360335d525ac2bf887bdd7ba4fe03a (diff) | |
download | nextcloud-server-9071e756a103319c6747974292463f30b89ab4e3.tar.gz nextcloud-server-9071e756a103319c6747974292463f30b89ab4e3.zip |
Fix for broken ajax/share.php endpoint
Even more code mess :(
All tests pass again. But I'm really not happy with this endpoint.
Diffstat (limited to 'core/ajax')
-rw-r--r-- | core/ajax/share.php | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/core/ajax/share.php b/core/ajax/share.php index 4738d0e0827..a1c573900c9 100644 --- a/core/ajax/share.php +++ b/core/ajax/share.php @@ -48,9 +48,28 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo $shareType = (int)$_POST['shareType']; $shareWith = $_POST['shareWith']; $itemSourceName = isset($_POST['itemSourceName']) ? (string)$_POST['itemSourceName'] : null; - if ($shareType === OCP\Share::SHARE_TYPE_LINK && $shareWith == '') { - $shareWith = null; + + /* + * Nasty nasty fix for https://github.com/owncloud/core/issues/19950 + */ + $passwordChanged = null; + if (is_array($shareWith)) { + $passwordChanged = ($shareWith['passwordChanged'] === 'true'); + if ($shareType === OCP\Share::SHARE_TYPE_LINK && $shareWith['password'] === '') { + $shareWith = null; + } else { + $shareWith = $shareWith['password']; + } + } else { + /* + * We need this branch since the calendar and contacts also use this + * endpoint + */ + if ($shareType === OCP\Share::SHARE_TYPE_LINK && $shareWith === '') { + $shareWith = null; + } } + $itemSourceName=(isset($_POST['itemSourceName'])) ? (string)$_POST['itemSourceName']:''; $token = OCP\Share::shareItem( @@ -60,7 +79,8 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo $shareWith, $_POST['permissions'], $itemSourceName, - (!empty($_POST['expirationDate']) ? new \DateTime((string)$_POST['expirationDate']) : null) + (!empty($_POST['expirationDate']) ? new \DateTime((string)$_POST['expirationDate']) : null), + $passwordChanged ); if (is_string($token)) { |