View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000622 | file | General | public | 2025-02-07 18:46 | 2025-02-07 18:46 |
Reporter | Odd_Bloke | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | new | Resolution | open | ||
Product Version | 5.46 | ||||
Summary | 0000622: Incorrect mime type for zip files when using magic_buffer | ||||
Description | Using `python3-magic` as the interface, `magic.from_buffer(..., mime=True)` against a zip file with libmagic 5.45 installed returns the expected `application/zip` but with libmagic 5.46 installed returns `application/octet-stream` instead. Note that unlike https://bugs.astron.com/view.php?id=612, the `file` command does return the expected `application/zip` with both library versions. The issue I'm hitting does sound like the issue ifoancea mentioned in the first comment on that issue. | ||||
Steps To Reproduce | Using Docker to reproduce with 5.46 (with irrelevant output redacted for readability): $ docker run -t cgr.dev/chainguard/wolfi-base sh -c ' apk add file libmagic py3-magic python3 zip touch test_file zip test.zip test_file file --mime test.zip python3 -c "import magic; file = open(\"test.zip\",\"rb\"); print(magic.from_buffer(file.read(), mime=True))"' fetch https://packages.wolfi.dev/os/x86_64/APKINDEX.tar.gz (1/18) Installing libmagic (5.46-r1) (2/18) Installing file (5.46-r1) ... OK: 69 MiB in 33 packages adding: test_file (stored 0%) test.zip: application/zip; charset=binary application/octet-stream and to see the expected behaviour on the previous version (note the version specifiers on the file and libmagic packages): $ docker run -t cgr.dev/chainguard/wolfi-base sh -c ' apk add file\<5.46 libmagic\<5.46 py3-magic python3 zip touch test_file zip test.zip test_file file --mime test.zip python3 -c "import magic; file = open(\"test.zip\",\"rb\"); print(magic.from_buffer(file.read(), mime=True))"' fetch https://packages.wolfi.dev/os/x86_64/APKINDEX.tar.gz (1/18) Installing libmagic (5.45-r4) (2/18) Installing file (5.45-r4) ... OK: 67 MiB in 33 packages adding: test_file (stored 0%) test.zip: application/zip; charset=binary application/zip | ||||
Additional Information | (I have also tested a build of master from GitHub and observed the same unexpected behaviour.) | ||||
Tags | No tags attached. | ||||
Date Modified | Username | Field | Change |
---|---|---|---|
2025-02-07 18:46 | Odd_Bloke | New Issue |