aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2014-09-08 17:26:20 +0200
committerLukas Reschke <lukas@owncloud.com>2014-09-08 17:26:20 +0200
commitc79c894dbb6bda06ff32db4418b8fe6af5b27d4a (patch)
tree8291661d30277963db03424d6d84d4e31ffbf837 /lib
parenta92d6f3c50abc71bc02d2ddb0ae8896e9bf438c6 (diff)
parentecc9b42e4143773e4a850d6ee385328b16cda813 (diff)
downloadnextcloud-server-c79c894dbb6bda06ff32db4418b8fe6af5b27d4a.tar.gz
nextcloud-server-c79c894dbb6bda06ff32db4418b8fe6af5b27d4a.zip
Merge pull request #10755 from owncloud/shorter_sharing_links
Shorter sharing links
Diffstat (limited to 'lib')
-rw-r--r--lib/private/helper.php12
-rw-r--r--lib/private/share/constants.php2
-rw-r--r--lib/private/share/share.php5
3 files changed, 11 insertions, 8 deletions
diff --git a/lib/private/helper.php b/lib/private/helper.php
index 7c1edd1b058..f696b5a8900 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -129,12 +129,12 @@ class OC_Helper {
* Returns a absolute url to the given service.
*/
public static function linkToPublic($service, $add_slash = false) {
- return OC::$server->getURLGenerator()->getAbsoluteURL(
- self::linkTo(
- '', 'public.php') . '?service=' . $service
- . (($add_slash && $service[strlen($service) - 1] != '/') ? '/' : ''
- )
- );
+ if ($service === 'files') {
+ $url = OC::$server->getURLGenerator()->getAbsoluteURL('/s');
+ } else {
+ $url = OC::$server->getURLGenerator()->getAbsoluteURL(self::linkTo('', 'public.php').'?service='.$service);
+ }
+ return $url . (($add_slash && $service[strlen($service) - 1] != '/') ? '/' : '');
}
/**
diff --git a/lib/private/share/constants.php b/lib/private/share/constants.php
index 4c398c43c2d..798327cc154 100644
--- a/lib/private/share/constants.php
+++ b/lib/private/share/constants.php
@@ -34,7 +34,7 @@ class Constants {
const FORMAT_STATUSES = -2;
const FORMAT_SOURCES = -3; // ToDo Check if it is still in use otherwise remove it
- const TOKEN_LENGTH = 32; // see db_structure.xml
+ const TOKEN_LENGTH = 15; // old (oc7) length is 32, keep token length in db at least that for compatibility
protected static $shareTypeUserAndGroups = -1;
protected static $shareTypeGroupUserUnique = 2;
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index e2e9b94125e..8441e6a94c4 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -640,7 +640,10 @@ class Share extends \OC\Share\Constants {
if (isset($oldToken)) {
$token = $oldToken;
} else {
- $token = \OC_Util::generateRandomBytes(self::TOKEN_LENGTH);
+ $token = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(self::TOKEN_LENGTH,
+ \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_UPPER.
+ \OCP\Security\ISecureRandom::CHAR_DIGITS
+ );
}
$result = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions,
null, $token, $itemSourceName, $expirationDate);