fix(files): extract extension from basename in ObjectStoreStorage::fopen - #64197
Open
Bytepie wants to merge 2 commits into
Open
fix(files): extract extension from basename in ObjectStoreStorage::fopen#64197Bytepie wants to merge 2 commits into
Bytepie wants to merge 2 commits into
Conversation
Signed-off-by: Umer Tahir <umertahir6@gmail.com>
Bytepie
requested review from
Altahrim,
leftybournes,
salmart-dev and
sorbaugh
and removed request for
a team
September 10, 2026 17:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an issue in
ObjectStoreStorage::fopen()where the file extension is extracted usingstrrpos($path, '.')across the entire relative path instead ofbasename($path).Problem
When an extensionless file is located inside a folder containing a dot (e.g.
0. Projects/Subfolder/hit),$extis assigned the entire subpath string after the dot:When
TempManager::getTemporaryFile($ext)is called, directory separators are stripped:How we encountered it
In our production case, a user had deeply nested folders with Cyrillic names. Because Linux's
NAME_MAXlimit is 255 bytes (and Cyrillic takes 2 bytes per character in UTF-8), the flattened filename easily exceeded 255 bytes, causing Linux to reject it withENAMETOOLONG.TempManagerreturnedfalse, andfopen(false, $mode)crashed with:This fatal error killed the PHP process while the write lock was active, leaving behind orphaned exclusive locks in Redis.
Solution
basename($path)when extracting the file extension inObjectStoreStorage::fopen().falsereturn fromgetTemporaryFile()before invokingfopen().testFopenWriteInDottedDirectoryWithoutExtensiontoObjectStoreStorageTest.php.Tests
Tested against live Nextcloud container where I had this issue during migration of data from GlusterFS to S3 (Ceph), and verified with PHPUnit in
nextcloud-docker-devenvironment.Checklist
AI (if applicable)