lmmx / range-streams

Streaming range requests in Python
https://range-streams.readthedocs.io/en/latest/
MIT License
8 stars 0 forks source link

More robust null terminated field handling #42

Open lmmx opened 1 year ago

lmmx commented 1 year ago

In #41, @generalmimon replied to my suggestion that we use file_size_b[:file_size_b.index(b"\x00")] to strip null terminating bytes:

Yes. But bytes.index raises ValueError if the searched sequence is not found, so now it really makes sense to keep the try..except statement and apply the null termination only if int() on the original file_size_b fails.

And as I mentioned, this should be probably used for other fields (like file names) too.

Originally posted by @generalmimon in https://github.com/lmmx/range-streams/issues/41#issuecomment-1518411074

This ticket can be used to track this work: