diff options
author | kondou <kondou@ts.unde.re> | 2014-08-03 11:31:28 +0200 |
---|---|---|
committer | kondou <kondou@ts.unde.re> | 2014-09-04 15:23:55 +0200 |
commit | 2a4c51389c23ab1da47d52be9f2e76cd90f2df01 (patch) | |
tree | b50145fa66fe889045a0dbac963dd4b9865bf827 /core | |
parent | 0f2ad9862e98e00fdc250bf8405bf6404d40b1ed (diff) | |
download | nextcloud-server-2a4c51389c23ab1da47d52be9f2e76cd90f2df01.tar.gz nextcloud-server-2a4c51389c23ab1da47d52be9f2e76cd90f2df01.zip |
Use a route instead of s.php and convert tokens asap
Diffstat (limited to 'core')
-rw-r--r-- | core/ajax/share.php | 2 | ||||
-rw-r--r-- | core/js/js.js | 1 | ||||
-rw-r--r-- | core/js/share.js | 4 | ||||
-rw-r--r-- | core/js/tests/specs/shareSpec.js | 6 | ||||
-rw-r--r-- | core/routes.php | 5 | ||||
-rw-r--r-- | core/share/controller.php | 23 |
6 files changed, 33 insertions, 8 deletions
diff --git a/core/ajax/share.php b/core/ajax/share.php index 536f0e2ebd8..c6da79a8a42 100644 --- a/core/ajax/share.php +++ b/core/ajax/share.php @@ -46,8 +46,6 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo (!empty($_POST['expirationDate']) ? new \DateTime($_POST['expirationDate']) : null) ); - $token = base_convert($token, 16, 36); - if (is_string($token)) { OC_JSON::success(array('data' => array('token' => $token))); } else { diff --git a/core/js/js.js b/core/js/js.js index 9a60b0aad69..bf33e3f2e48 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -246,6 +246,7 @@ var OC={ url = '/' + url; } + // TODO save somewhere whether the webserver is able to skip the index.php to have shorter links (e.g. for sharing) return OC.webroot + '/index.php' + _build(url, params); }, diff --git a/core/js/share.js b/core/js/share.js index d00b5f1ccf9..67ddd9c4870 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -663,8 +663,6 @@ OC.Share={ // TODO: use oc webroot ? var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=files&'+type+'='+encodeURIComponent(file); } else { - // convert the token to base36 - //token = parseInt(token, 16).toString(36); //TODO add path param when showing a link to file in a subfolder of a public link share var service=''; if(linkSharetype === 'folder' || linkSharetype === 'file'){ @@ -677,7 +675,7 @@ OC.Share={ if (service !== 'files') { var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service='+service+'&t='+token; } else { - var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 's.php')+'?t='+token; + var link = parent.location.protocol+'//'+location.host+OC.generateUrl('/s/')+token; } } $('#linkText').val(link); diff --git a/core/js/tests/specs/shareSpec.js b/core/js/tests/specs/shareSpec.js index 06c4b98df2a..e712ea58bc2 100644 --- a/core/js/tests/specs/shareSpec.js +++ b/core/js/tests/specs/shareSpec.js @@ -151,7 +151,7 @@ describe('OC.Share tests', function() { expect($('#dropdown #linkCheckbox').prop('checked')).toEqual(true); // this is how the OC.Share class does it... var link = parent.location.protocol + '//' + location.host + - OC.linkTo('', 'public.php')+'?service=files&t=tehtoken'; + OC.generateUrl('/s/') + 'tehtoken'; expect($('#dropdown #linkText').val()).toEqual(link); }); it('does not show populated link share when a link share exists for a different file', function() { @@ -243,7 +243,7 @@ describe('OC.Share tests', function() { expect($('#dropdown #linkCheckbox').prop('checked')).toEqual(true); // this is how the OC.Share class does it... var link = parent.location.protocol + '//' + location.host + - OC.linkTo('', 'public.php')+'?service=files&t=tehtoken'; + OC.generateUrl('/s/') + 'tehtoken'; expect($('#dropdown #linkText').val()).toEqual(link); // nested one @@ -258,7 +258,7 @@ describe('OC.Share tests', function() { expect($('#dropdown #linkCheckbox').prop('checked')).toEqual(true); // this is how the OC.Share class does it... link = parent.location.protocol + '//' + location.host + - OC.linkTo('', 'public.php')+'?service=files&t=anothertoken'; + OC.generateUrl('/s/') + 'anothertoken'; expect($('#dropdown #linkText').val()).toEqual(link); }); describe('expiration date', function() { diff --git a/core/routes.php b/core/routes.php index 28a3680dd91..fac67f23175 100644 --- a/core/routes.php +++ b/core/routes.php @@ -100,6 +100,11 @@ $this->create('core_avatar_post_cropped', '/avatar/cropped') ->post() ->action('OC\Core\Avatar\Controller', 'postCroppedAvatar'); +// Sharing routes +$this->create('core_share_show_share', '/s/{token}') + ->get() + ->action('OC\Core\Share\Controller', 'showShare'); + // used for heartbeat $this->create('heartbeat', '/heartbeat')->action(function(){ // do nothing diff --git a/core/share/controller.php b/core/share/controller.php new file mode 100644 index 00000000000..c1741af0d98 --- /dev/null +++ b/core/share/controller.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright (c) 2014 Christopher Schäpers <christopher@schaepers.it> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Core\Share; + +class Controller { + public static function showShare($args) { + \OC_Util::checkAppEnabled('files_sharing'); + + $token = $args['token']; + + \OC_App::loadApp('files_sharing'); + \OC_User::setIncognitoMode(true); + + require_once \OC_App::getAppPath('files_sharing') .'/public.php'; + } +} +?> |