Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
ececa907
Commit
ececa907
authored
9 years ago
by
Vincent Petry
Browse files
Options
Downloads
Patches
Plain Diff
Set download cookie on public download
parent
cd818e74
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/files_sharing/lib/controllers/sharecontroller.php
+15
-1
15 additions, 1 deletion
apps/files_sharing/lib/controllers/sharecontroller.php
with
15 additions
and
1 deletion
apps/files_sharing/lib/controllers/sharecontroller.php
+
15
−
1
View file @
ececa907
...
@@ -233,9 +233,10 @@ class ShareController extends Controller {
...
@@ -233,9 +233,10 @@ class ShareController extends Controller {
* @param string $token
* @param string $token
* @param string $files
* @param string $files
* @param string $path
* @param string $path
* @param string $downloadStartSecret
* @return void|RedirectResponse
* @return void|RedirectResponse
*/
*/
public
function
downloadShare
(
$token
,
$files
=
null
,
$path
=
''
)
{
public
function
downloadShare
(
$token
,
$files
=
null
,
$path
=
''
,
$downloadStartSecret
=
''
)
{
\OC_User
::
setIncognitoMode
(
true
);
\OC_User
::
setIncognitoMode
(
true
);
$linkItem
=
OCP\Share
::
getShareByToken
(
$token
,
false
);
$linkItem
=
OCP\Share
::
getShareByToken
(
$token
,
false
);
...
@@ -288,6 +289,19 @@ class ShareController extends Controller {
...
@@ -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
// download selected files
if
(
!
is_null
(
$files
))
{
if
(
!
is_null
(
$files
))
{
// FIXME: The exit is required here because otherwise the AppFramework is trying to add headers as well
// FIXME: The exit is required here because otherwise the AppFramework is trying to add headers as well
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment