Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
c6be1ba8
Commit
c6be1ba8
authored
Mar 27, 2015
by
Bjoern Schiessle
Browse files
fix check if a file is excluded from encryption or not
parent
7e73b255
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/private/encryption/util.php
View file @
c6be1ba8
...
...
@@ -389,9 +389,22 @@ class Util {
* @return boolean
*/
public
function
isExcluded
(
$path
)
{
$root
=
explode
(
'/'
,
$path
,
2
);
if
(
isset
(
$root
[
0
]))
{
if
(
in_array
(
$root
[
0
],
$this
->
excludedPaths
))
{
$normalizedPath
=
\
OC\Files\Filesystem
::
normalizePath
(
$path
);
$root
=
explode
(
'/'
,
$normalizedPath
,
4
);
if
(
count
(
$root
)
>
2
)
{
//detect system wide folders
if
(
in_array
(
$root
[
1
],
$this
->
excludedPaths
))
{
return
true
;
}
$v1
=
$this
->
userManager
->
userExists
(
$root
[
1
]);
$v2
=
in_array
(
$root
[
2
],
$this
->
excludedPaths
);
// detect user specific folders
if
(
$this
->
userManager
->
userExists
(
$root
[
1
])
&&
in_array
(
$root
[
2
],
$this
->
excludedPaths
))
{
return
true
;
}
}
...
...
lib/private/files/storage/wrapper/encryption.php
View file @
c6be1ba8
...
...
@@ -254,7 +254,7 @@ class Encryption extends Wrapper {
'" not found, file will be stored unencrypted'
);
}
if
(
$shouldEncrypt
===
true
&&
!
$this
->
util
->
isExcluded
(
$
p
ath
)
&&
$encryptionModule
!==
null
)
{
if
(
$shouldEncrypt
===
true
&&
!
$this
->
util
->
isExcluded
(
$
fullP
ath
)
&&
$encryptionModule
!==
null
)
{
$source
=
$this
->
storage
->
fopen
(
$path
,
$mode
);
$handle
=
\
OC\Files\Stream\Encryption
::
wrap
(
$source
,
$path
,
$fullPath
,
$header
,
$this
->
uid
,
$encryptionModule
,
$this
->
storage
,
$this
,
$this
->
util
,
$mode
,
...
...
tests/lib/encryption/utiltest.php
View file @
c6be1ba8
...
...
@@ -98,4 +98,39 @@ class UtilTest extends TestCase {
$u
->
createHeader
(
$header
,
$em
);
}
/**
* @dataProvider providePathsForTestIsExcluded
*/
public
function
testIsEcluded
(
$path
,
$expected
)
{
$this
->
userManager
->
expects
(
$this
->
any
())
->
method
(
'userExists'
)
->
will
(
$this
->
returnCallback
(
array
(
$this
,
'isExcludedCallback'
)));
$u
=
new
Util
(
$this
->
view
,
$this
->
userManager
);
$this
->
assertSame
(
$expected
,
$u
->
isExcluded
(
$path
)
);
}
public
function
providePathsForTestIsExcluded
()
{
return
array
(
array
(
'files_encryption/foo.txt'
,
true
),
array
(
'test/foo.txt'
,
false
),
array
(
'/user1/files_encryption/foo.txt'
,
true
),
array
(
'/user1/files/foo.txt'
,
false
),
);
}
public
function
isExcludedCallback
()
{
$args
=
func_get_args
();
if
(
$args
[
0
]
===
'user1'
)
{
return
true
;
}
return
false
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment