Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@darkliquid
Copy link
Contributor

Brotli annoyingly lacks magic bits/headers making content-sniffing it quite difficult. We now employ multiple heuristics including:

  • checking for errors reading the first 16 bytes
  • checking to see if the decompressed data exists in the input stream
  • reading in chunks of 16 bytes up until 128 bytes have been read, checking for errors that would indicate a corrupt archive (which we can infer is us actually trying to decompress non-brotli data)

Fixes #29

Also forces update to the latest brotli package commit which includes some relevant fixes as there isn't a new official release tag yet.

Brotli annoyingly lacks magic bits/headers making content-sniffing it
quite difficult. We now employ multiple heuristics including:
- checking for errors reading the first 16 bytes
- checking to see if the decompressed data exists in the input stream
- reading in chunks of 16 bytes up until 128 bytes have been read,
  checking for errors that would indicate a corrupt archive (which we
  can infer is us actually trying to decompress non-brotli data)
Copy link
Owner

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, thanks! Let's give this a shot!

@mholt mholt merged commit 4393d88 into mholt:main Apr 25, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Brotli compression detection is unreliable

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.