Add brotli mime type detection to file and libmagic #259

Open
opened 2026-01-29 20:40:57 +00:00 by claunia · 6 comments
Owner

Originally created by @stokito on GitHub (Oct 27, 2018).

The Linux file utility doesn't recognize brotli MIME type:

$ file -i some_archive.br
some_archive.br: application/octet-stream; charset=binary

I know, this is not related for the brotli itself but could you send a PR to file and libmagic so they start to recognize brotli mime type?

https://github.com/file/file/blob/master/src/compress.c
https://github.com/file/file/blob/master/magic/Magdir/archive

Also please confirm the correct brotli mime type #724

Originally created by @stokito on GitHub (Oct 27, 2018). The Linux `file` utility doesn't recognize brotli MIME type: ``` $ file -i some_archive.br some_archive.br: application/octet-stream; charset=binary ``` I know, this is not related for the brotli itself but could you send a PR to file and libmagic so they start to recognize brotli mime type? https://github.com/file/file/blob/master/src/compress.c https://github.com/file/file/blob/master/magic/Magdir/archive Also please confirm the correct brotli mime type #724
Author
Owner

@eustas commented on GitHub (Nov 1, 2018):

There is a little problem. Most utilities scan first file bytes and compare them against "magic" bytes.
Well,... for brotli 254 of 256 byte values are valid as the first file byte.

Brotli was designed to be "stream" format rather than file format. There is a "brotli-framing-format" project that adds tons of features (including "magic header bytes")... but it is not public yet.

@eustas commented on GitHub (Nov 1, 2018): There is a little problem. Most utilities scan first file bytes and compare them against "magic" bytes. Well,... for brotli 254 of 256 byte values are valid as the first file byte. Brotli was designed to be "stream" format rather than file format. There is a "brotli-framing-format" project that adds tons of features (including "magic header bytes")... but it is not public yet.
Author
Owner

@stokito commented on GitHub (Nov 1, 2018):

If I understood correctly gzip is also can be named as stream format but this is not a problem for them to add few magic bytes.
I already used \xce\xb2\xcf\x81 as brotli magic bytes and application/x-brotli as mime type but asked here #724 to confirm.

Where can I read at least something about this framing format? Will we still be able to use regular .br files?

@stokito commented on GitHub (Nov 1, 2018): If I understood correctly gzip is also can be named as stream format but this is not a problem for them to add few magic bytes. I [already used](https://github.com/mate-desktop/engrampa/blob/master/src/fr-archive.c#L555) `\xce\xb2\xcf\x81` as brotli magic bytes and `application/x-brotli` as mime type but asked here #724 to confirm. Where can I read at least something about this framing format? Will we still be able to use regular .br files?
Author
Owner

@eustas commented on GitHub (Nov 1, 2018):

gzip is a wrapper for deflate streams

@eustas commented on GitHub (Nov 1, 2018): `gzip` is a wrapper for `deflate` streams
Author
Owner

@stokito commented on GitHub (Nov 10, 2018):

So, the magic bytes which I used are actually from another framing format from #462

@stokito commented on GitHub (Nov 10, 2018): So, the magic bytes which I used are actually from another framing format from #462
Author
Owner

@doronbehar commented on GitHub (Oct 6, 2019):

I've opened an issue about this in file's bug tracker:

https://bugs.astron.com/view.php?id=111

So @eustas, the issue is that this implementation doesn't include magic bytes when it creates files and not streams?

@doronbehar commented on GitHub (Oct 6, 2019): I've opened an issue about this in `file`'s bug tracker: https://bugs.astron.com/view.php?id=111 So @eustas, the issue is that this implementation doesn't include magic bytes when it creates files and not streams?
Author
Owner

@unphased commented on GitHub (Aug 4, 2024):

What is the state of this? Most (but not all! which is not looking promising) of the brotli files i looked at start with the byte 5b...

@unphased commented on GitHub (Aug 4, 2024): What is the state of this? Most (but not all! which is not looking promising) of the brotli files i looked at start with the byte `5b`...
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#259