Skip to content

__detect_mime_type is broken #35

@weddige

Description

@weddige

__detect_mime_type has a bug in line 66/67:

ezodf/ezodf/document.py

Lines 56 to 68 in f9675c1

def __detect_mime_type(file_manager):
mime_type = file_manager.get_text('mimetype')
if mime_type is not None:
return mime_type
# Fall-through to next mechanism
entry = file_manager.manifest.find('/')
if entry is not None:
mime_type = entry.get(CN('manifest:media-type'))
else:
# use file ext name
ext = os.path.splitext(file_manager.zipname)[1]
mime_type = MIMETYPES[ext]
return mime_type

os.path.splitext returns the file extension with a leading dot (e. g. .ods). But MIMETYPES only contains the extensions without the dot:

'ots': "application/vnd.oasis.opendocument.spreadsheet-template",

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