Correct handling of trailing zeros in _rle_encode

This commit is contained in:
Anton Marfei 2025-09-21 13:20:31 +02:00
parent 859a83a1a5
commit 7494cdf4c9
2 changed files with 6 additions and 0 deletions

View File

@ -1095,6 +1095,8 @@ def _rle_encode(string):
count = 0
new += bytes([cur])
if count != 0:
new += b'\0' + bytes([count])
return new

View File

@ -52,3 +52,7 @@ def test_private_get_extension():
assert utils._get_extension(empty_buffer) == ''
assert utils._get_extension(empty_buffer) == '' # make sure it did seek back
assert utils._get_extension(CustomFd('foo')) == ''
def test_rle_encode_trailing_zeros():
assert utils._rle_encode(b'\x12\x00\x00\x00\x00') == b'\x12\x00\x04'