Skip to content

BOM causes MalformedFileError in from_buffer #71

@Frenzie

Description

@Frenzie

If you use the following sample file with .from_buffer() you receive a MalformedFileError error.

srt-with-bom.zip

webvtt.from_buffer(io.StringIO(caption_file_from_upload.read().decode('utf-8')), "srt")

It may not be a bug because it's solved by using:

webvtt.from_buffer(io.StringIO(caption_file_from_upload.read().decode('utf-8-sig')), "srt")

See https://docs.python.org/3/library/codecs.html#encodings-and-unicode

But it doesn't happen with .from_srt(), which strips out the BOM by itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions