diff options
author | Julius Härtl <jus@bitgrid.net> | 2019-05-28 16:29:18 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-05-28 16:29:18 +0300 |
commit | 9c8eadd913b99da1f4c903110944baf75312fdb1 (patch) | |
tree | 88f4edfb6a4c65eb334ddbda4f36b7454057e9fe /lib | |
parent | c08ea17d74d8104750832b738f683f4a8d7ece58 (diff) |
Allow UTF8 characters in filenames
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Controller/OCSController.php | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/Controller/OCSController.php b/lib/Controller/OCSController.php index cbb93c73..7b9b70cf 100644 --- a/lib/Controller/OCSController.php +++ b/lib/Controller/OCSController.php @@ -146,7 +146,7 @@ class OCSController extends \OCP\AppFramework\OCSController { throw new OCSBadRequestException('Invalid template provided'); } - $info = pathinfo($path); + $info = $this->mb_pathinfo($path); $userFolder = $this->rootFolder->getUserFolder($this->userId); $folder = $userFolder->get($info['dirname']); @@ -165,4 +165,22 @@ class OCSController extends \OCP\AppFramework\OCSController { throw new OCSNotFoundException(); } } + + private function mb_pathinfo($filepath) { + $result = []; + preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im',$filepath,$matches); + if($matches[1]) { + $result['dirname'] = $matches[1]; + } + if($matches[2]) { + $result['basename'] = $matches[2]; + } + if($matches[5]) { + $result['extension'] = $matches[5]; + } + if($matches[3]) { + $result['filename'] = $matches[3]; + } + return $result; + } } |