Skip to content

fix(files): extract extension from basename in ObjectStoreStorage::fopen - #64197

Closed
Bytepie wants to merge 2 commits into
nextcloud:masterfrom
Bytepie:fix/objectstore-fopen-basename-ext
Closed

Bytepie wants to merge 2 commits into
nextcloud:masterfrom
Bytepie:fix/objectstore-fopen-basename-ext

Conversation

@Bytepie

@Bytepie Bytepie commented Sep 10, 2026 •

Copy link
Copy Markdown

Summary

Fixes an issue in ObjectStoreStorage::fopen() where the file extension is extracted using strrpos($path, '.') across the entire relative path instead of basename($path).

Problem

When an extensionless file is located inside a folder containing a dot (e.g. 0. Projects/Subfolder/hit), $ext is assigned the entire subpath string after the dot:

$ext = ". Projects/Subfolder/hit"

When TempManager::getTemporaryFile($ext) is called, directory separators are stripped:

/tmp/oc_tmp_<32_chars>. ProjectsSubfolderhit

Solution

  1. Use basename($path) when extracting the file extension

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-dev environment.

  • [Backports requested]

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Signed-off-by: Umer Tahir <umertahir6@gmail.com>
@Bytepie
Bytepie requested a review from a team as a code owner September 10, 2026 17:11
@Bytepie
Bytepie requested review from Altahrim, leftybournes, salmart-dev and sorbaugh and removed request for a team September 10, 2026 17:11
@solracsf solracsf added this to the Nextcloud 36 milestone Sep 12, 2026
@icewind1991

Copy link
Copy Markdown
Member

As per our AI Policy, the PR description needs to be human written, which this does not appear to be. So I'm closing this issue for violating the policy.

If this is not the case, feel free to re-open.

@github-actions

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

@Bytepie

Bytepie commented Sep 25, 2026 •

Copy link
Copy Markdown
Author

Hi, @icewind1991 , I have made the PR again with only what I wrote. I couldn't open this one may be I don't have permission.
64770.

Kindly review it again. I spent good amount of time to work on this issue and in trying to contribute it into nextcloud/server for the first time. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants