diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2014-02-20 11:53:58 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2014-02-20 11:53:58 +0100 |
commit | 719f1111b636a854d22e8d8a5423629eeb07dc75 (patch) | |
tree | 615036d16a34090b4c9d4dbee439b90018d83d69 /lib/private/util.php | |
parent | 8114843973d62b33bb9611634b28f220b5b59e2b (diff) | |
parent | bd71a1b7b66f02b3630da44e24b48e29f3d02f17 (diff) | |
download | nextcloud-server-719f1111b636a854d22e8d8a5423629eeb07dc75.tar.gz nextcloud-server-719f1111b636a854d22e8d8a5423629eeb07dc75.zip |
Merge pull request #6714 from owncloud/files-newfileinvalidcharsfix
Added extra checks for invalid file chars in newfile.php and newfolder.php
Diffstat (limited to 'lib/private/util.php')
-rwxr-xr-x | lib/private/util.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/private/util.php b/lib/private/util.php index 829eedce044..b7856436527 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -1155,4 +1155,25 @@ class OC_Util { } return $version; } + + /** + * Returns whether the given file name is valid + * @param $file string file name to check + * @return bool true if the file name is valid, false otherwise + */ + public static function isValidFileName($file) { + $trimmed = trim($file); + if ($trimmed === '') { + return false; + } + if ($trimmed === '.' || $trimmed === '..') { + return false; + } + foreach (str_split($trimmed) as $char) { + if (strpos(\OCP\FILENAME_INVALID_CHARS, $char) !== false) { + return false; + } + } + return true; + } } |