Skip to content

GFile S3 reader may corrupt files containing multibyte characters or CR/LF #2839

@davidsoergel

Description

@davidsoergel

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

(Followup to #2791 and #2777)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions