[Bug]: mimetype inconsistency between `Detection.detectPath` and `Loader.updateFilecache`
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 713
Description
⚠️ This issue respects the following points: ⚠️
- This is a bug, not a question or a configuration/webserver/proxy issue.
- This issue is not already reported on Github (I've searched it).
- Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- Nextcloud Server is running on 64bit capable CPU, PHP and OS.
- I agree to follow Nextcloud's Code of Conduct.
Bug description
For files named like .ext e.g. ".gpx", ".ext" or ".maps" get different mimetypes by
https://github.com/nextcloud/server/blob/ce1dddcc642f8de6887a48e778942969b8223d57/lib/private/Files/Type/Detection.php#L195
or
https://github.com/nextcloud/server/blob/ce1dddcc642f8de6887a48e778942969b8223d57/lib/private/Files/Type/Loader.php#L164.
To clearify its about files which start with a . and then just have the extension.
Therefore existing files get different mime-types then new file.
Steps to reproduce
- Create ".ext" file
- Run Loader->updateFilecache("ext", mimeTypeId)
- Create corresponding Mimetype mapping
- Uploade a file called ".ext" to a different folder
- See that it gets a different Mimetype
Expected behavior
- Get the same Mimetype
- It would be nice if it would be the Mimetype in the mapping, then mimetypes can be used to find .noindex and .nomedia files, or in maps a .maps file. Searching the file over the mimetype is faster as there is a db index.
Installation method
None
Operating system
None
PHP engine version
None
Web server
None
Database engine version
MySQL
Is this bug present after an update or on a fresh install?
None
Are you using the Nextcloud Server Encryption module?
None
What user-backends are you using?
- Default user-backend (database)
- LDAP/ Active Directory
- SSO - SAML
- Other
Configuration report
No response
List of activated Apps
[]
Nextcloud Signing status
No response
Nextcloud Logs
No response
Additional info
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with lib/private/Files/Type/Detection.php near line 195 and lib/private/Files/Type/Loader.php near line 164, comparing how names such as .ext are handled. Reproduce the listed file-cache and upload steps, then verify that both paths assign the mimetype from the corresponding mapping consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100