[Bug]: Detection::detectString() / detectContent() never use finfo – missing use finfo; (regression from #54077)
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
lib/private/Files/Type/Detection.php から始めます。detectContent() と detectString() は、use finfo; のインポートがないまま finfo::class と new finfo(...) を参照しているため、検索結果は OC\Files\Type\finfo に解決されます。不足しているグローバルインポートを追加し、ext-fileinfo が読み込まれている場合に finfo の分岐が実行されることを確認してください。heise.de の favicon.ico のバイト列に対して detectString() が application/octet-stream ではなく image/vnd.microsoft.icon を返せば完了です。
索引モデルが issue の本文から書いたものです。
説明
⚠️ This issue respects the following points: ⚠️
- This is not a troubleshooting question, general support matter, or webserver/proxy problem, but likely a bug (if unsure, ask the Community Help Forum).
- This issue is not already reported on Github OR solved at the Community Help Forum (I've searched!).
- I'm using a maintained major version of Nextcloud Server and tested against the latest patch level. (Supported major versions and current patch levels).
- I agree to follow Nextcloud's Code of Conduct.
- I've tried my best to provide clear reproduction steps that someone unfamiliar with this bug could use to reproduce it.
Bug description
Since #54077 (refactor(IMimeTypeDetector): streamline finfo usage + misc tidying), lib/private/Files/Type/Detection.php uses class_exists(finfo::class) and new finfo(...). The file is in namespace OC\Files\Type, but there is no use finfo; import. finfo::class therefore resolves to OC\Files\Type\finfo, class_exists() is always false, and the finfo branch never runs, even when ext-fileinfo is loaded.
Affected: detectString() (line ~302) and detectContent() (line ~228). Present in v35.0.2, stable34, stable35 and master.
Effect: detectString() falls back to writing a temp file and calling detect() → detectContent() → mime_content_type(). That result goes through getSecureMimeType(), which maps MIME types that are not in the mimetype list (e.g. image/vnd.microsoft.icon) to application/octet-stream. Before the refactor, finfo_buffer() returned the real type.
Visible consequence: In the Mail app, favicon avatars no longer show up. FaviconSource calls IMimeTypeDetector::detectString(), gets application/octet-stream for .ico favicons, and AvatarService::hasAllowedMime() rejects the result. I suspect this is also why FaviconSourceTest::testFetchNoCacheFiles was dropped as "flaky" in nextcloud/mail#12578.
Steps to reproduce
<?php
require 'lib/base.php';
$d = \OCP\Server::get(\OCP\Files\IMimeTypeDetector::class);
$ico = file_get_contents('https://heise.de/favicon.ico');
var_dump(class_exists('OC\Files\Type\finfo')); // false
var_dump($d->detectString($ico)); // "application/octet-stream"
var_dump((new \finfo(FILEINFO_MIME_TYPE))->buffer($ico)); // "image/vnd.microsoft.icon"
Expected behavior
detectString() returns image/vnd.microsoft.icon, as it did before #54077.
Nextcloud Server version
35
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.4
Web server
Nginx
Database engine version
PostgreSQL
Is this bug present after an update or on a fresh install?
None
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
- Default user-backend (database)
- LDAP/ Active Directory
- SSO - SAML
- Other
Configuration report
List of activated Apps
Nextcloud Signing status
Nextcloud Logs
Additional info
No response
- 主要言語
- PHP
- スター
- 37.3k
- フォーク
- 5.3k
- 平均マージ
- 2日 14時間
- マージ済み PR(30日)
- 636
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nextcloud/server のほかの issue
-
[Bug]: DAV Forbidden/InvalidPath responses break on "&" in the message (DOMDocument::createElementNS(): unterminated entity reference)対応中かも @th-joerger が 1 日前に担当しました。 オープン0. Needs triage 35-feedback bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: Files folder-tree API eagerly lists the children of every subfolder at the last requested depth, then discards them (N extra directory listings per request)対応中かも @lazerg が 3 日前に担当しました。 オープン0. Needs triage 34-feedback bug
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
nextcloud/server#65904 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: Contradictory notifications when cancelling welcome email confirmation対応中かも @Jashan32 が 5 日前に担当しました。 オープン0. Needs triage 36-feedback bug
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 1 日以内に返信
-
`OutOfOfficeEventDispatcherJob` is not cleaned up correctly対応中かも @MishowHD が 4 日前に担当しました。 オープン1. to develop bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
nextcloud/server の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
getgrav/grav-plugin-api#74 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
heroku/heroku-buildpack-php#1024 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
PHPOffice/PhpSpreadsheet#5091 ·
メンテナーはふだん 3 日以内に返信