From 05615bfd473f1eafa4ec253779568ab044467ceb Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Sat, 10 Jan 2015 00:06:30 +0100 Subject: 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 --- lib/private/files/filesystem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') 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; -- cgit v1.2.3