-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
In our stub GFile implementation, the S3 reader obtains chunks of n bytes and then decodes them as strings. This risks corrupting data or at least throwing decoding errors, because the byte chunk may end in the middle of a multibyte character (and correspondingly, the next chunk would begin in the middle of that character).
Thus the chunks cannot be decoded independently. Any partial character must be detected and removed from the end of each chunk, and prepended to the subsequent chunk before decoding.
CRLF (\r\n) is effectively a multibyte character in this context, because Python always "decodes" it to just \n.
See
| # TODO(orionr): This endpoint risks splitting a multi-byte |