summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-01-10 00:06:30 +0100
committerLukas Reschke <lukas@owncloud.com>2015-01-10 00:40:21 +0100
commit05615bfd473f1eafa4ec253779568ab044467ceb (patch)
tree3c850b8089684a62a988b3c725477ab6ba998e85 /lib
parent59a1d16d0fd3d67833bfb728ce03cebc7fec4043 (diff)
downloadnextcloud-server-05615bfd473f1eafa4ec253779568ab044467ceb.tar.gz
nextcloud-server-05615bfd473f1eafa4ec253779568ab044467ceb.zip
Simplify isValidPath and add unit tests
The check for invalid paths is actually over-complicated and performed twice resulting in a performance penalty. Additionally, I decided to add unit-tests to that function. Part of https://github.com/owncloud/core/issues/13221
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/filesystem.php2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php
index ed2be59c092..506813f73f0 100644
--- a/lib/private/files/filesystem.php
+++ b/lib/private/files/filesystem.php
@@ -502,7 +502,7 @@ class Filesystem {
if (!$path || $path[0] !== '/') {
$path = '/' . $path;
}
- if (strstr($path, '/../') || strrchr($path, '/') === '/..') {
+ if (strpos($path, '/../') !== FALSE || strrchr($path, '/') === '/..') {
return false;
}
return true;