소스 검색

Set download cookie on public download

tags/v8.2RC2
Vincent Petry 8 년 전
부모
커밋
ececa90709
1개의 변경된 파일15개의 추가작업 그리고 1개의 파일을 삭제
  1. 15
    1
      apps/files_sharing/lib/controllers/sharecontroller.php

+ 15
- 1
apps/files_sharing/lib/controllers/sharecontroller.php 파일 보기

@@ -233,9 +233,10 @@ class ShareController extends Controller {
* @param string $token
* @param string $files
* @param string $path
* @param string $downloadStartSecret
* @return void|RedirectResponse
*/
public function downloadShare($token, $files = null, $path = '') {
public function downloadShare($token, $files = null, $path = '', $downloadStartSecret = '') {
\OC_User::setIncognitoMode(true);

$linkItem = OCP\Share::getShareByToken($token, false);
@@ -288,6 +289,19 @@ class ShareController extends Controller {
}
}

/**
* this sets a cookie to be able to recognize the start of the download
* the content must not be longer than 32 characters and must only contain
* alphanumeric characters
*/
if (!empty($downloadStartSecret)
&& !isset($downloadStartSecret[32])
&& preg_match('!^[a-zA-Z0-9]+$!', $downloadStartSecret) === 1) {

// FIXME: set on the response once we use an actual app framework response
setcookie('ocDownloadStarted', $downloadStartSecret, time() + 20, '/');
}

// download selected files
if (!is_null($files)) {
// FIXME: The exit is required here because otherwise the AppFramework is trying to add headers as well

Loading…
취소
저장