php / php/php-src

Allow to resolve known mime type to file extension

未关闭
#12,918 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Extension: fileinfo Feature Status: Needs Triage
主要语言
C
星标
40.4k
派生
8.2k
平均合并
2 天 13 小时
30 天内合并 PR
96

描述

Description

Mime type to file extension is already supported by FILEINFO_EXTENSION but it is impossible to specify the mime type :).

I expect code like:

$mimetype = 'application/zip';
$finfo = finfo_open(FILEINFO_EXTENSION);
var_dump(finfo_buffer($finfo, $mimetype, FILEINFO_EXTENSION)); // notice $mimetype is mime type not file data

to dump zip.

It should be possible to find the file magic data by iterating the magic data like in https://github.com/file/file/blob/FILE5_45/src/softmagic.c#L135, the mime/ext is defined in https://github.com/file/file/blob/FILE5_45/src/file.h#L371.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 finfo_open 和 finfo_buffer 入口点开始,将请求的行为与 file's softmagic.c 和 file.h 中的引用进行比较。跟踪 FILEINFO_EXTENSION 当前如何解析数据,然后验证诸如 application/zip 这样的 MIME 类型输入会生成 zip,同时不改变现有行为。为新的解析路径添加或更新有针对性的测试。

由索引模型根据 Issue 内容生成。

评估

技术栈
c, php
领域
api, backend
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。