Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [
["3.8", "py38"],
["3.9", "py39"],
["3.10", "py310"],
["3.11", "py311"],
Expand Down Expand Up @@ -96,7 +95,7 @@ jobs:
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: "cp38-* pp*-* cp314t-*"
CIBW_BUILD: "cp39-* pp*-* cp314t-*"
CIBW_SKIP: "*musllinux*"
CIBW_ENABLE: pypy
CIBW_ARCHS_LINUX: auto aarch64
Expand Down
6 changes: 2 additions & 4 deletions src/brotlicffi/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,8 @@ def _decompress(self, data, output_buffer_limit):
chunks.append(chunk)
chunks_len += len(chunk)

# Save any unconsumed input for the next call.
if available_in[0] > 0:
remaining_input = ffi.buffer(next_in[0], available_in[0])[:]
self._unconsumed_data = remaining_input
# Save input for the next call
self._unconsumed_data = ffi.buffer(next_in[0], available_in[0])[:]

# Check if we've reached the output limit.
if (
Expand Down
19 changes: 19 additions & 0 deletions test/test_simple_decompression.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,25 @@ def test_decompressobj_with_output_buffer_limit(
assert final_result == uncompressed_data


def test_high_expansion_prefix_without_output_buffer_limit():
"""
A fully-consumed mid-stream chunk must not leave stale unconsumed
input behind (issue #225).
"""
uncompressed = b''.join(
bytes([65 + (i % 26)]) * 4096 for i in range(16)
)
compressed = brotlicffi.compress(uncompressed, lgwin=12)
assert len(compressed) > 64

o = brotlicffi.Decompressor()
result = o.decompress(compressed[:64])
assert not o._unconsumed_data
assert o.can_accept_more_data()
result += o.decompress(compressed[64:])
assert result == uncompressed


def test_drip_feed(simple_compressed_file):
"""
Sending in the data one byte at a time still works.
Expand Down
Loading