[Bug]: Detection::detectString() / detectContent() never use finfo – missing use finfo; (regression from #54077)

オープン 初心者向け
#66,239 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@lazerg がすでに取り組んでいます。

2026年11月4日 から。

  • #66246 @lazerg による — オープン

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
62/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php
領域
backend

調査の方向性

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 の本文から書いたものです。

説明

0. Needs triage 35-feedback bug
⚠️ 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

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nextcloud/server のほかの issue

nextcloud/server の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。