Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
fb899460
Commit
fb899460
authored
Mar 27, 2015
by
Thomas Müller
Browse files
Options
Downloads
Plain Diff
Merge pull request #15252 from owncloud/prevent-directory-characters-in-temporary-path
Filter potential dangerous characters in path name
parents
71049840
9622fbdf
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/private/tempmanager.php
+5
-0
5 additions, 0 deletions
lib/private/tempmanager.php
tests/lib/tempmanager.php
+13
-0
13 additions, 0 deletions
tests/lib/tempmanager.php
with
18 additions
and
0 deletions
lib/private/tempmanager.php
+
5
−
0
View file @
fb899460
...
@@ -54,10 +54,15 @@ class TempManager implements ITempManager {
...
@@ -54,10 +54,15 @@ class TempManager implements ITempManager {
$this
->
log
=
$logger
;
$this
->
log
=
$logger
;
}
}
/**
* @param string $postFix
* @return string
*/
protected
function
generatePath
(
$postFix
)
{
protected
function
generatePath
(
$postFix
)
{
if
(
$postFix
)
{
if
(
$postFix
)
{
$postFix
=
'.'
.
ltrim
(
$postFix
,
'.'
);
$postFix
=
'.'
.
ltrim
(
$postFix
,
'.'
);
}
}
$postFix
=
str_replace
([
'\\'
,
'/'
],
''
,
$postFix
);
return
$this
->
tmpBaseDir
.
'/oc_tmp_'
.
md5
(
time
()
.
rand
())
.
$postFix
;
return
$this
->
tmpBaseDir
.
'/oc_tmp_'
.
md5
(
time
()
.
rand
())
.
$postFix
;
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/lib/tempmanager.php
+
13
−
0
View file @
fb899460
...
@@ -151,4 +151,17 @@ class TempManager extends \Test\TestCase {
...
@@ -151,4 +151,17 @@ class TempManager extends \Test\TestCase {
->
with
(
$this
->
stringContains
(
'Can not create a temporary folder in directory'
));
->
with
(
$this
->
stringContains
(
'Can not create a temporary folder in directory'
));
$this
->
assertFalse
(
$manager
->
getTemporaryFolder
());
$this
->
assertFalse
(
$manager
->
getTemporaryFolder
());
}
}
public
function
testGeneratePathTraversal
()
{
$logger
=
$this
->
getMock
(
'\Test\NullLogger'
);
$tmpManager
=
\Test_Helper
::
invokePrivate
(
$this
->
getManager
(
$logger
),
'generatePath'
,
[
'../Traversal\\../FileName'
]
);
$this
->
assertStringEndsNotWith
(
'./Traversal\\../FileName'
,
$tmpManager
);
$this
->
assertStringEndsWith
(
'.Traversal..FileName'
,
$tmpManager
);
}
}
}
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