Skip to content
Snippets Groups Projects
Commit 8057bc66 authored by Morris Jobke's avatar Morris Jobke
Browse files

Merge pull request #13236 from owncloud/use-isset-for-performance

Use isset() instead of strlen()
parents 74d1a9ea 310424db
No related branches found
No related tags found
No related merge requests found
......@@ -1278,8 +1278,10 @@ class View {
private function assertPathLength($path) {
$maxLen = min(PHP_MAXPATHLEN, 4000);
$pathLen = strlen($path);
if ($pathLen > $maxLen) {
// Check for the string length - performed using isset() instead of strlen()
// because isset() is about 5x-40x faster.
if(isset($path[$maxLen])) {
$pathLen = strlen($path);
throw new \OCP\Files\InvalidPathException("Path length($pathLen) exceeds max path length($maxLen): $path");
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment