summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-03-11 14:38:41 +0100
committerMorris Jobke <hey@morrisjobke.de>2015-03-11 14:38:41 +0100
commitdbade1936206256f55f89c3f865be4046b8fb546 (patch)
tree40d0a30811d17d5e3ae26fe9348ac404eff0673d /lib
parentad97ceb787ed859e01305d350acce2739d36be53 (diff)
parentb180724cd083d82cb8468c637e1a30e8f0ec993d (diff)
downloadnextcloud-server-dbade1936206256f55f89c3f865be4046b8fb546.tar.gz
nextcloud-server-dbade1936206256f55f89c3f865be4046b8fb546.zip
Merge pull request #13839 from owncloud/issue/13678-improve-remote-domain-detection-in-sharedropdown
Better finding the remote URL from user input in share dropdown
Diffstat (limited to 'lib')
-rw-r--r--lib/private/share/helper.php30
-rw-r--r--lib/private/share/share.php2
2 files changed, 31 insertions, 1 deletions
diff --git a/lib/private/share/helper.php b/lib/private/share/helper.php
index 6059af0196d..55b71ceeeac 100644
--- a/lib/private/share/helper.php
+++ b/lib/private/share/helper.php
@@ -221,4 +221,34 @@ class Helper extends \OC\Share\Constants {
return $expires;
}
+
+ /**
+ * Extracts the necessary remote name from a given link
+ *
+ * Strips away a potential file name, to allow
+ * - user
+ * - user@localhost
+ * - user@http://localhost
+ * - user@http://localhost/
+ * - user@http://localhost/index.php
+ * - user@http://localhost/index.php/s/{shareToken}
+ *
+ * @param string $shareWith
+ * @return string
+ */
+ public static function fixRemoteURLInShareWith($shareWith) {
+ if (strpos($shareWith, '@')) {
+ list($user, $remote) = explode('@', $shareWith, 2);
+
+ $remote = str_replace('\\', '/', $remote);
+ if ($fileNamePosition = strpos($remote, '/index.php')) {
+ $remote = substr($remote, 0, $fileNamePosition);
+ }
+ $remote = rtrim($remote, '/');
+
+ $shareWith = $user . '@' . $remote;
+ }
+
+ return rtrim($shareWith, '/');
+ }
}
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index 4753f6ecbfa..974ebf41f93 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -724,7 +724,7 @@ class Share extends \OC\Share\Constants {
$token = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(self::TOKEN_LENGTH, \OCP\Security\ISecureRandom::CHAR_LOWER . \OCP\Security\ISecureRandom::CHAR_UPPER .
\OCP\Security\ISecureRandom::CHAR_DIGITS);
- $shareWith = rtrim($shareWith, '/');
+ $shareWith = Helper::fixRemoteURLInShareWith($shareWith);
$shareId = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, null, $token, $itemSourceName);
$send = false;