ahupp / ahupp/python-magic

`from_buffer()` issue with file-5.47

Open
#362 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.9k
Forks
304
PR merge metrics
No merged PRs in 30d

Description

Using archlinux, with python-magic 0.4.27, there seems to be an issue with file-5.47-1 and python-magic when using from_buffer

In [1]: import magic

In [2]: magic.from_file("sample.mp4", mime=True)
Out[2]: 'video/mp4'

In [3]: magic.from_buffer(open("sample.mp4", "rb").read(2048), mime=True)
Out[3]: 'application/octet-stream'

In [4]: magic.from_file("sample.webm", mime=True)
Out[4]: 'video/webm'

In [5]: magic.from_buffer(open("sample.webm", "rb").read(2048), mime=True)
Out[5]: 'application/octet-stream'

after downgrading to file-5.46-5 everything works

In [1]: import magic

In [2]: magic.from_file("sample.mp4", mime=True)
Out[2]: 'video/mp4'

In [3]: magic.from_buffer(open("sample.mp4", "rb").read(2048), mime=True)
Out[3]: 'video/mp4'

In [4]: magic.from_file("sample.webm", mime=True)
Out[4]: 'video/webm'

In [5]: magic.from_buffer(open("sample.webm", "rb").read(2048), mime=True)
Out[5]: 'video/webm'

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the from_buffer and from_file examples on Arch Linux with python-magic 0.4.27 and file-5.47, then compare with file-5.46-5. Inspect the from_buffer path and its interaction with libmagic. Done means video/mp4 and video/webm are returned for the buffer calls under file-5.47.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.