From 14fc5f5a937bda3b1cb3ba6a450359d723440283 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 4 Apr 2013 16:50:51 -0700 Subject: [PATCH] [FileBackend] Disallow files ending in / and clarified some docs. Change-Id: I162ca34fe9f92d862345004bd184013531da9e8d --- includes/filebackend/FileBackendStore.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/includes/filebackend/FileBackendStore.php b/includes/filebackend/FileBackendStore.php index 8b280e0bb0..46ec177965 100644 --- a/includes/filebackend/FileBackendStore.php +++ b/includes/filebackend/FileBackendStore.php @@ -1417,7 +1417,13 @@ abstract class FileBackendStore extends FileBackend { /** * Like resolveStoragePath() except null values are returned if - * the container is sharded and the shard could not be determined. + * the container is sharded and the shard could not be determined + * or if the path ends with '/'. The later case is illegal for FS + * backends and can confuse listings for object store backends. + * + * This function is used when resolving paths that must be valid + * locations for files. Directory and listing functions should + * generally just use resolveStoragePath() instead. * * @see FileBackendStore::resolveStoragePath() * @@ -1426,7 +1432,7 @@ abstract class FileBackendStore extends FileBackend { */ final protected function resolveStoragePathReal( $storagePath ) { list( $container, $relPath, $cShard ) = $this->resolveStoragePath( $storagePath ); - if ( $cShard !== null ) { + if ( $cShard !== null && substr( $relPath, -1 ) !== '/' ) { return array( $container, $relPath ); } return array( null, null ); -- 2.20.1