[Bug]: Detection::detectString() / detectContent() never use finfo – missing use finfo; (regression from #54077)
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức phù hợp với người mới
- 62/100
Hướng nghiên cứu
Bắt đầu ở lib/private/Files/Type/Detection.php, nơi detectContent() và detectString() tham chiếu finfo::class và new finfo(...) mà không có import use finfo;, nên việc tra cứu được phân giải thành OC\Files\Type\finfo. Thêm import toàn cục còn thiếu và xác nhận nhánh finfo chạy khi ext-fileinfo được tải. Hoàn thành khi detectString() trả về image/vnd.microsoft.icon thay vì application/octet-stream với các byte của favicon.ico từ heise.de.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
⚠️ 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
- Ngôn ngữ chính
- PHP
- Star
- 37.4k
- Fork
- 5.3k
- Merge trung bình
- 2 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 744
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của nextcloud/server
-
34-feedback
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: DAV Forbidden/InvalidPath responses break on "&" in the message (DOMDocument::createElementNS(): unterminated entity reference)Có thể đã có người làm @th-joerger đã nhận 3 ngày trước. Đang mở0. Needs triage 35-feedback bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[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)Có thể đã có người làm @lazerg đã nhận 5 ngày trước. Đang mở0. Needs triage 34-feedback bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
nextcloud/server#65904 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Contradictory notifications when cancelling welcome email confirmationCó thể đã có người làm @Jashan32 đã nhận 6 ngày trước. Đang mở0. Needs triage 36-feedback bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của nextcloud/server
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Author mapping step: "create new user" and "assign to existing user" fields have no spacing between themCó thể đã có người làm @umeshnevase đã nhận hôm nay. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
WordPress/wordpress-importer#275 ·
-
security/openvpn-legacy: read-only user can stop a running VPNCó thể đã có người làm @besendorf đã nhận hôm nay. Đang mởincomplete
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
opnsense/plugins#5887 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
jira-created
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
-
No Code Attached Yet
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
joomla/joomla-cms#48786 ·
Maintainer thường phản hồi trong vòng 1 ngày