[FileBackend] Disallow files ending in / and clarified some docs.
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 4 Apr 2013 23:50:51 +0000 (16:50 -0700)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 19 Apr 2013 03:30:14 +0000 (03:30 +0000)
Change-Id: I162ca34fe9f92d862345004bd184013531da9e8d

includes/filebackend/FileBackendStore.php

index 8b280e0..46ec177 100644 (file)
@@ -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 );