summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2015-02-02 19:54:56 +0100
committerJoas Schilling <nickvergessen@gmx.de>2015-02-23 11:28:41 +0100
commitb180724cd083d82cb8468c637e1a30e8f0ec993d (patch)
tree21ef42a28e14625a7d8c1fa2954e81de85e24581 /lib
parent0d8b3afc32f15b1582bbf555796b9d112a91a4ef (diff)
downloadnextcloud-server-b180724cd083d82cb8468c637e1a30e8f0ec993d.tar.gz
nextcloud-server-b180724cd083d82cb8468c637e1a30e8f0ec993d.zip
Extract the remote host from user input in share dropdown
Fix #13678
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 bd21bdd4b3a..0a630806dc4 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;