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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
aa821ecc
Commit
aa821ecc
authored
10 years ago
by
Vincent Petry
Browse files
Options
Downloads
Patches
Plain Diff
Trim leading or trailing slashes in file cache paths
parent
10505bdb
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/private/files/cache/cache.php
+1
-1
1 addition, 1 deletion
lib/private/files/cache/cache.php
tests/lib/files/cache/cache.php
+36
-0
36 additions, 0 deletions
tests/lib/files/cache/cache.php
with
37 additions
and
1 deletion
lib/private/files/cache/cache.php
+
1
−
1
View file @
aa821ecc
...
@@ -699,6 +699,6 @@ class Cache {
...
@@ -699,6 +699,6 @@ class Cache {
*/
*/
public
function
normalize
(
$path
)
{
public
function
normalize
(
$path
)
{
return
\OC_Util
::
normalizeUnicode
(
$path
);
return
trim
(
\OC_Util
::
normalizeUnicode
(
$path
)
,
'/'
)
;
}
}
}
}
This diff is collapsed.
Click to expand it.
tests/lib/files/cache/cache.php
+
36
−
0
View file @
aa821ecc
...
@@ -517,6 +517,42 @@ class Cache extends \Test\TestCase {
...
@@ -517,6 +517,42 @@ class Cache extends \Test\TestCase {
$this
->
assertEquals
(
1
,
count
(
$this
->
cache
->
getFolderContents
(
'folder'
)));
$this
->
assertEquals
(
1
,
count
(
$this
->
cache
->
getFolderContents
(
'folder'
)));
}
}
function
bogusPathNamesProvider
()
{
return
array
(
array
(
'/bogus.txt'
,
'bogus.txt'
),
array
(
'//bogus.txt'
,
'bogus.txt'
),
array
(
'bogus/'
,
'bogus'
),
array
(
'bogus//'
,
'bogus'
),
);
}
/**
* Test bogus paths with leading or doubled slashes
*
* @dataProvider bogusPathNamesProvider
*/
public
function
testBogusPaths
(
$bogusPath
,
$fixedBogusPath
)
{
$data
=
array
(
'size'
=>
100
,
'mtime'
=>
50
,
'mimetype'
=>
'httpd/unix-directory'
);
// put root folder
$this
->
assertFalse
(
$this
->
cache
->
get
(
''
));
$parentId
=
$this
->
cache
->
put
(
''
,
$data
);
$this
->
assertGreaterThan
(
0
,
$parentId
);
$this
->
assertGreaterThan
(
0
,
$this
->
cache
->
put
(
$bogusPath
,
$data
));
$newData
=
$this
->
cache
->
get
(
$fixedBogusPath
);
$this
->
assertNotFalse
(
$newData
);
$this
->
assertEquals
(
$fixedBogusPath
,
$newData
[
'path'
]);
// parent is the correct one, resolved properly (they used to not be)
$this
->
assertEquals
(
$parentId
,
$newData
[
'parent'
]);
$newDataFromBogus
=
$this
->
cache
->
get
(
$bogusPath
);
// same entry
$this
->
assertEquals
(
$newData
,
$newDataFromBogus
);
}
protected
function
tearDown
()
{
protected
function
tearDown
()
{
if
(
$this
->
cache
)
{
if
(
$this
->
cache
)
{
$this
->
cache
->
clear
();
$this
->
cache
->
clear
();
...
...
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